summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2010-11-18 07:38:34 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2010-11-18 08:27:43 (GMT)
commit8c31c6529935cd9ee6f99bc38cfd182d5b3182e2 (patch)
tree25cf4e9fb4c01a6cd518b0278381dd7931357266 /src
parent506c4285213c8da30f16a3b94b8e8ffdcab444e2 (diff)
downloadQt-8c31c6529935cd9ee6f99bc38cfd182d5b3182e2.zip
Qt-8c31c6529935cd9ee6f99bc38cfd182d5b3182e2.tar.gz
Qt-8c31c6529935cd9ee6f99bc38cfd182d5b3182e2.tar.bz2
Don't destroy Qt's internal pthread_key_t if it was not initialized
The destructor function destroy_current_thread_data_key() was always called on library unload, even if the pthread_key_t was not initialized. This can cause us to destroy a key that doesn't belong to us, as pointed out in the task below. Fix this by creating a function static instance of a class whose destructor will destroy the key. Task-number: QTBUG-10861 Reviewed-by: Morten Sørvig
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qthread_unix.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index f508c0a..75bc78a 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -136,15 +136,17 @@ static void destroy_current_thread_data(void *p)
static void create_current_thread_data_key()
{
pthread_key_create(&current_thread_data_key, destroy_current_thread_data);
+ static class destroy_current_thread_data_key
+ {
+ public:
+ ~destroy_current_thread_data_key()
+ {
+ pthread_key_delete(current_thread_data_key);
+ }
+ } d;
+ Q_UNUSED(d);
}
-static void destroy_current_thread_data_key()
-{
- pthread_key_delete(current_thread_data_key);
-}
-Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
-
-
// Utility functions for getting, setting and clearing thread specific data.
// In Symbian, TLS access is significantly faster than pthread_getspecific.
// However Symbian does not have the thread destruction cleanup functionality