diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-11-22 14:24:53 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-11-22 14:42:56 (GMT) |
commit | 6cc3f97adfb541acfa7bffde6ca8b91fdc980854 (patch) | |
tree | 99f76b7698e87d51cc05ea038f8f3fd2f4a9e74a /src/corelib/thread | |
parent | dd8ae3d39b9181bebcba6ea60fb9edc2aea0a4e2 (diff) | |
download | Qt-6cc3f97adfb541acfa7bffde6ca8b91fdc980854.zip Qt-6cc3f97adfb541acfa7bffde6ca8b91fdc980854.tar.gz Qt-6cc3f97adfb541acfa7bffde6ca8b91fdc980854.tar.bz2 |
Revert "Don't destroy Qt's internal pthread_key_t if it was not initialized"
This reverts commit 8c31c6529935cd9ee6f99bc38cfd182d5b3182e2 due to a
regression in the QThreadStorage autotest.
Fix the problem another way: call pthread_once() in the destructor function
to ensure that we always call pthread_key_delete() on a key we created.
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index c578955..adbbad2 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -136,16 +136,16 @@ static void destroy_current_thread_data(void *p) static void create_current_thread_data_key() { pthread_key_create(¤t_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; } +static void destroy_current_thread_data_key() +{ + pthread_once(¤t_thread_data_once, create_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 |