summaryrefslogtreecommitdiffstats
path: root/src/kernel
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2024-03-19 05:56:36 +0300
committerAlexander Golubev <fatzer2@gmail.com>2024-03-29 13:47:58 +0300
commit676000853b614b9063e38568e94833683bf05ccd (patch)
treeb54f928f010d01a04a0ba5cdf79b516a527aebc8 /src/kernel
parentfb0d62eec811ab2d4d73550e455944cecbe7e091 (diff)
downloadtqt3-676000853b614b9063e38568e94833683bf05ccd.tar.gz
tqt3-676000853b614b9063e38568e94833683bf05ccd.zip
Improve TQFont-related cleanup
Improve TQFont cleanup making sure that all instances of TQFont are destroyed before TQApplication (or specifically before disconnect from X11). This gets reed of several valgrind complains about leaks deep inside fontconfig. Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/ntqobject.h1
-rw-r--r--src/kernel/qapplication.cpp6
-rw-r--r--src/kernel/qfont_x11.cpp1
-rw-r--r--src/kernel/qobject.cpp7
-rw-r--r--src/kernel/qrichtext_p.cpp21
-rw-r--r--src/kernel/qrichtext_p.h1
6 files changed, 36 insertions, 1 deletions
diff --git a/src/kernel/ntqobject.h b/src/kernel/ntqobject.h
index fc16c50bd..a2b12d4fa 100644
--- a/src/kernel/ntqobject.h
+++ b/src/kernel/ntqobject.h
@@ -145,6 +145,7 @@ public:
TQStyleControlElementData* controlElementDataObject();
TQStyleControlElementDataPrivate* controlElementDataPrivateObject();
+ void cleanupControlElementData();
#ifndef TQT_NO_PROPERTIES
virtual bool setProperty( const char *name, const TQVariant& value );
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp
index e8658cdab..403757e52 100644
--- a/src/kernel/qapplication.cpp
+++ b/src/kernel/qapplication.cpp
@@ -1203,6 +1203,12 @@ TQApplication::~TQApplication()
tqt_desktopWidget = 0;
is_app_closing = TRUE;
+ // Due to hacks to speadup TQStyle engine (see git hash 523c1fd99) TQObjects now contain a
+ // reference to TQStyleControlElementData object which among other contain TQFont memebers.
+ // But for a proper cleanup all fonts should be destroyed before disconnecting from X11 (in
+ // tqt_cleanup()). So we will have to cleanup up the data explicitly.
+ cleanupControlElementData();
+
#ifndef TQT_NO_CLIPBOARD
delete tqt_clipboard;
tqt_clipboard = 0;
diff --git a/src/kernel/qfont_x11.cpp b/src/kernel/qfont_x11.cpp
index 9f86734a4..3cd207c65 100644
--- a/src/kernel/qfont_x11.cpp
+++ b/src/kernel/qfont_x11.cpp
@@ -312,6 +312,7 @@ void TQFont::cleanup()
{
// delete the global font cache
delete TQFontCache::instance;
+ TQFontCache::instance = 0;
}
/*!
diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp
index 3ab2d9b97..bb4c848b8 100644
--- a/src/kernel/qobject.cpp
+++ b/src/kernel/qobject.cpp
@@ -134,6 +134,13 @@ TQStyleControlElementDataPrivate* TQObject::controlElementDataPrivateObject() {
return d->controlElementDataPrivate;
}
+void TQObject::cleanupControlElementData() {
+ delete d->controlElementData;
+ d->controlElementData = 0;
+ delete d->controlElementDataPrivate;
+ d->controlElementDataPrivate = 0;
+}
+
#if defined(TQT_THREAD_SUPPORT)
void TQObject::moveToThread_helper(TQThread *targetThread)
diff --git a/src/kernel/qrichtext_p.cpp b/src/kernel/qrichtext_p.cpp
index 4411b4d45..022eb13de 100644
--- a/src/kernel/qrichtext_p.cpp
+++ b/src/kernel/qrichtext_p.cpp
@@ -337,6 +337,19 @@ int TQTextFormat::pntr_asc=-1;
int TQTextFormat::pntr_hei=-1;
int TQTextFormat::pntr_dsc=-1;
+void TQTextFormat::cleanupPrivateData() {
+ delete TQTextFormat::pntr_fm;
+ TQTextFormat::pntr_fm = 0;
+ TQTextFormat::pntr = 0;
+
+ // Not really necessary, but better to tidy-up everything
+ TQTextFormat::pntr_fm = 0;
+ TQTextFormat::pntr_ldg=-1;
+ TQTextFormat::pntr_asc=-1;
+ TQTextFormat::pntr_hei=-1;
+ TQTextFormat::pntr_dsc=-1;
+}
+
void TQTextFormat::setPainter( TQPainter *p )
{
pntr = p;
@@ -350,10 +363,16 @@ TQPainter* TQTextFormat::painter()
void TQTextFormat::applyFont( const TQFont &f )
{
TQFontMetrics fm( pntr->fontMetrics() );
+
+ if ( !pntr_fm ) {
+ tqAddPostRoutine( &TQTextFormat::cleanupPrivateData );
+ }
+
if ( !pntr_fm
|| pntr_fm->painter != pntr
|| pntr_fm->d != fm.d
- || !pntr->font().isCopyOf( f ) ) {
+ || !pntr->font().isCopyOf( f )
+ ) {
pntr->setFont( f );
delete pntr_fm;
pntr_fm = new TQFontMetrics( pntr->fontMetrics() );
diff --git a/src/kernel/qrichtext_p.h b/src/kernel/qrichtext_p.h
index df6b0a272..428b0ec5d 100644
--- a/src/kernel/qrichtext_p.h
+++ b/src/kernel/qrichtext_p.h
@@ -1561,6 +1561,7 @@ protected:
private:
void update();
static void applyFont( const TQFont &f );
+ static void cleanupPrivateData();
private:
TQFont fn;