From e1bb179fdec82544a3de80a0d51c2700fa27c0f5 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Tue, 19 Mar 2024 06:32:17 +0300 Subject: [PATCH] inputmethods/xim: fix incorrect fontset ref counting - rename fontsetRefCount -> fontsetCacheRefCount - move fontsetCacheRefCount to constructor as setHolderWidget() could be called more than once Signed-off-by: Alexander Golubev --- plugins/src/inputmethods/xim/qximinputcontext_x11.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp b/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp index 20ca4424..e56df9d9 100644 --- a/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp +++ b/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp @@ -116,7 +116,7 @@ extern "C" { much as possible */ static XFontSet fontsetCache[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; -static int fontsetRefCount = 0; +static int fontsetCacheRefCount = 0; static const char * const fontsetnames[] = { "-*-fixed-medium-r-*-*-16-*,-*-*-medium-r-*-*-16-*", @@ -345,6 +345,8 @@ TQXIMInputContext::TQXIMInputContext() TQXIMInputContext::init_xim(); #if !defined(TQT_NO_XIM) + fontsetCacheRefCount++; + if( ! ximContextList ) ximContextList = new TQPtrList; ximContextList->append( this ); @@ -360,7 +362,6 @@ void TQXIMInputContext::setHolderWidget( TQWidget *widget ) TQInputContext::setHolderWidget( widget ); #if !defined(TQT_NO_XIM) - fontsetRefCount++; if (! qt_xim) { tqWarning("TQInputContext: no input method context available"); return; @@ -441,7 +442,7 @@ TQXIMInputContext::~TQXIMInputContext() if (ic) XDestroyIC((XIC) ic); - if ( --fontsetRefCount == 0 ) { + if ( --fontsetCacheRefCount == 0 ) { Display *dpy = TQPaintDevice::x11AppDisplay(); for ( int i = 0; i < 8; i++ ) { if ( fontsetCache[i] && fontsetCache[i] != (XFontSet)-1 ) {