summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2024-03-16 08:43:59 +0300
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-03-16 19:32:15 +0900
commit4bed6be8623bd95cee11fc9ea758db70a7ca1789 (patch)
treeb0186cb4c3292d194c244f7b37a7c012346043c1
parentd730db2c0d934174635a3b850b00dccf2dbb871f (diff)
downloadtqt3-4bed6be8623bd95cee11fc9ea758db70a7ca1789.tar.gz
tqt3-4bed6be8623bd95cee11fc9ea758db70a7ca1789.zip
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> (cherry picked from commit 1278ed0dad0a51d280d7b8b934a9280b459b107c)
-rw-r--r--plugins/src/inputmethods/xim/qximinputcontext_x11.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp b/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp
index e9dbcdd2..20ca4424 100644
--- a/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp
+++ b/plugins/src/inputmethods/xim/qximinputcontext_x11.cpp
@@ -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
}