From c9932b7c1a3ecfc2f4a8c4fbc18e9260e302962d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 3 Oct 2024 11:46:57 +0900 Subject: [PATCH] Make sure to release thread resources back to the OS once the thread completes. Threads created with pthread are created in detach mode. Threads created using glib thread functions are instead created as joinable. The fix makes glib-created threads detached, so that the thread resources are released when the thread completes. This resolves TDE/amarok#30 and will benefit any place where a TQThread is used. Manually cherry-picked from commit 81288cfc. Signed-off-by: Michele Calgaro --- src/kernel/qthread_unix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kernel/qthread_unix.cpp b/src/kernel/qthread_unix.cpp index be67e002..b68b5cd7 100644 --- a/src/kernel/qthread_unix.cpp +++ b/src/kernel/qthread_unix.cpp @@ -129,6 +129,7 @@ void *TQThreadInstance::start( void *_arg ) #if defined(QT_USE_GLIBMAINLOOP) // This is the first time we have access to the native pthread ID of this newly created thread ((TQThreadInstance*)arg[1])->thread_id = pthread_self(); + pthread_detach(pthread_self()); #endif // QT_USE_GLIBMAINLOOP #ifdef QT_DEBUG