From 323382b1896ae350cf5d6b10949c647e4465b3b9 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Sat, 16 Mar 2024 08:31:50 +0300 Subject: Fix TQThreadStorage destruction in the main thread Before that the allocations of TQThreadStorage objects from the main thread were never destroyed and memory associated with them were never freed. The second one isn't a huge problem as at that point program is terminating anyway (but it still makes valgrind complain). The first one is the bigger issue as destructors might contain some essential external cleanups like removing temporary files. Also make `TQApplication::guiThread()` return `0` when the thread is destroyed (may happen on the program exiting during destruction of statics). Signed-off-by: Alexander Golubev (cherry picked from commit b1e6f384640525c5a0caceef017848f8ebee46b8) --- src/kernel/qthread_unix.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/kernel/qthread_unix.cpp') diff --git a/src/kernel/qthread_unix.cpp b/src/kernel/qthread_unix.cpp index 7a6bc3393..6a6f81b7f 100644 --- a/src/kernel/qthread_unix.cpp +++ b/src/kernel/qthread_unix.cpp @@ -180,6 +180,11 @@ void TQThreadInstance::finish( void * ) } } +void TQThreadInstance::finishGuiThread(TQThreadInstance *d) { + TQThreadStorageData::finish( d->thread_storage ); + d->thread_storage = 0; +} + TQMutex *TQThreadInstance::mutex() const { return qt_thread_mutexpool ? qt_thread_mutexpool->get( (void *) this ) : 0; -- cgit v1.2.1