summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2010-04-08 09:27:44 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2010-04-08 11:45:27 (GMT)
commit20c3ad62b71b8c6beb93544e870ec00a42a35b07 (patch)
tree833a884a91fe8a2cd1afd717122c045792fc9929
parentb34817d3fce5b96c335cb583a3313e7bd9f8c07c (diff)
downloadQt-20c3ad62b71b8c6beb93544e870ec00a42a35b07.zip
Qt-20c3ad62b71b8c6beb93544e870ec00a42a35b07.tar.gz
Qt-20c3ad62b71b8c6beb93544e870ec00a42a35b07.tar.bz2
Fix a crash when unloading libQtCore
QThread will register a cleanup function with pthreads to be run when ever a thread exits. However, if QtCore is unloaded, this function would stay registered and the application would crash when a thread exits (since the function pointer registered with pthreads is no longer valid). Add a destructor function to qthread_unix.cpp which destroys the pthread_key_t and unregisters the cleanup function. Task-number: QTBUG-9436 Reviewed-by: Marius Storm-Olsen
-rw-r--r--src/corelib/thread/qthread_unix.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 5a50646..6b34b5f 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -136,6 +136,12 @@ static void create_current_thread_data_key()
pthread_key_create(&current_thread_data_key, destroy_current_thread_data);
}
+static void destroy_current_thread_data_key()
+{
+ pthread_key_delete(current_thread_data_key);
+}
+Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
+
QThreadData *QThreadData::current()
{
pthread_once(&current_thread_data_once, create_current_thread_data_key);