diff options
author | Marko Valtanen <marko.valtanen@digia.com> | 2012-01-10 15:29:37 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:25:11 (GMT) |
commit | 4fd8f368eac1941fc75f11423465ec00377d9aa4 (patch) | |
tree | 0a37ff5753bf1c119b305b68a13f4dd9da0cbe64 /src | |
parent | c81cf5590d24ef002716cc6c85051afc13db75e2 (diff) | |
download | Qt-4fd8f368eac1941fc75f11423465ec00377d9aa4.zip Qt-4fd8f368eac1941fc75f11423465ec00377d9aa4.tar.gz Qt-4fd8f368eac1941fc75f11423465ec00377d9aa4.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')
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 87979c4..5fdc799 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -150,17 +150,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; - Q_UNUSED(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 |