Fix a small memory leak in xim plugin

TQXIMInputContext::setHolderWidget() function may be (and actually is)
called more than once. This results in multiple instances of the same
object being added to ximContextList. But the destructor removes only
one instance, which effectively results in leak of several bytes
whenever a window is opened.

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
pull/126/head
Alexander Golubev 1 month ago committed by TDE Gitea
parent 8e4edc5883
commit 1278ed0dad

@ -343,6 +343,12 @@ TQXIMInputContext::TQXIMInputContext()
{
if(!isInitXIM)
TQXIMInputContext::init_xim();
#if !defined(TQT_NO_XIM)
if( ! ximContextList )
ximContextList = new TQPtrList<TQXIMInputContext>;
ximContextList->append( this );
#endif // !TQT_NO_XIM
}
@ -424,10 +430,6 @@ void TQXIMInputContext::setHolderWidget( TQWidget *widget )
// when resetting the input context, preserve the input state
(void) XSetICValues((XIC) ic, XNResetState, XIMPreserveState, (char *) 0);
if( ! ximContextList )
ximContextList = new TQPtrList<TQXIMInputContext>;
ximContextList->append( this );
#endif // !TQT_NO_XIM
}

Loading…
Cancel
Save