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 <fatzer2@gmail.com>
pull/137/head
Alexander Golubev 1 month ago committed by TDE Gitea
parent 7e24b2b61e
commit e1bb179fde

@ -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<TQXIMInputContext>;
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 ) {

Loading…
Cancel
Save