diff options
author | Alexander Golubev <fatzer2@gmail.com> | 2024-03-19 05:56:36 +0300 |
---|---|---|
committer | Alexander Golubev <fatzer2@gmail.com> | 2024-03-29 20:43:05 +0300 |
commit | ffbaaf0e1c181dd0f0d8ad7b273530f7cda086da (patch) | |
tree | 97be39accc7e8ba326d6e36d335405b69e810049 /src/kernel/qrichtext_p.cpp | |
parent | fb0d62eec811ab2d4d73550e455944cecbe7e091 (diff) | |
download | tqt3-ffbaaf0e1c181dd0f0d8ad7b273530f7cda086da.tar.gz tqt3-ffbaaf0e1c181dd0f0d8ad7b273530f7cda086da.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/qrichtext_p.cpp')
-rw-r--r-- | src/kernel/qrichtext_p.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
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() ); |