From 20c3ad62b71b8c6beb93544e870ec00a42a35b07 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 8 Apr 2010 11:27:44 +0200 Subject: 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 --- src/corelib/thread/qthread_unix.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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(¤t_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(¤t_thread_data_once, create_current_thread_data_key); -- cgit v0.12