From fa52f57da125cb9003526976f53656197a930879 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Fri, 29 Mar 2024 16:40:30 +0300 Subject: [PATCH] Reset TQThreadInstance::currentThread() value when destroying main thread This assures that TQRegExp who checks if there is an active thread through this interface won't try to access its already destroyed TQThreadLocalStorage, which might happen during destruction of static TQRegExp objects. Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tqt3/issues/142 Signed-off-by: Alexander Golubev --- src/kernel/qthread_unix.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kernel/qthread_unix.cpp b/src/kernel/qthread_unix.cpp index 6a6f81b7..1050512a 100644 --- a/src/kernel/qthread_unix.cpp +++ b/src/kernel/qthread_unix.cpp @@ -183,6 +183,9 @@ void TQThreadInstance::finish( void * ) void TQThreadInstance::finishGuiThread(TQThreadInstance *d) { TQThreadStorageData::finish( d->thread_storage ); d->thread_storage = 0; + + // Let all others (namely TQRegExp) know that the main thread is no longer alive + setCurrentThread(0); } TQMutex *TQThreadInstance::mutex() const