diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-23 04:46:43 +0200 |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-23 04:46:43 +0200 |
commit | bb2b9362ced23ff2aae824ef001efe7a34b464cc (patch) | |
tree | 4e24e98b8d648c63f4dea134d99ea928ef37ed83 /src/corelib | |
parent | db14623485396fd69839e519184b794775b65b01 (diff) | |
parent | 7bd52a15e03b5e8e83ec1f7ae957478ed9e0cde1 (diff) |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public:
Corrected build fail for autotests
QComboBox popup is shown in incorrect location with bottom CBA
QS60Style: The QComboBox/QSpinBox text color is not according to theme
Using TLS to store QThreadData on Symbian
Functions that are externally defined to QtOpenGL needs to be imported.
Added include for missing file for Symbian3
Support for clipboard between Qt and Symbian applications
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index a7601b654a..a44a0e811a 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -142,6 +142,39 @@ static void destroy_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 +// that pthread has, so pthread_setspecific is also used. +static QThreadData *get_thread_data() +{ +#ifdef Q_OS_SYMBIAN + return reinterpret_cast<QThreadData *>(Dll::Tls()); +#else + pthread_once(¤t_thread_data_once, create_current_thread_data_key); + return reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key)); +#endif +} + +static void set_thread_data(QThreadData *data) +{ +#ifdef Q_OS_SYMBIAN + qt_symbian_throwIfError(Dll::SetTls(data)); +#endif + pthread_once(¤t_thread_data_once, create_current_thread_data_key); + pthread_setspecific(current_thread_data_key, data); +} + +static void clear_thread_data() +{ +#ifdef Q_OS_SYMBIAN + Dll::FreeTls(); +#endif + pthread_setspecific(current_thread_data_key, 0); +} + + #ifdef Q_OS_SYMBIAN static void init_symbian_thread_handle(RThread &thread) { @@ -158,26 +191,24 @@ static void init_symbian_thread_handle(RThread &thread) QThreadData *QThreadData::current() { - pthread_once(¤t_thread_data_once, create_current_thread_data_key); - - QThreadData *data = reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key)); + QThreadData *data = get_thread_data(); if (!data) { void *a; if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) { QThread *adopted = static_cast<QThread*>(a); Q_ASSERT(adopted); data = QThreadData::get2(adopted); - pthread_setspecific(current_thread_data_key, data); + set_thread_data(data); adopted->d_func()->running = true; adopted->d_func()->finished = false; static_cast<QAdoptedThread *>(adopted)->init(); } else { data = new QThreadData; - pthread_setspecific(current_thread_data_key, data); QT_TRY { + set_thread_data(data); data->thread = new QAdoptedThread(data); } QT_CATCH(...) { - pthread_setspecific(current_thread_data_key, 0); + clear_thread_data(); data->deref(); data = 0; QT_RETHROW; @@ -268,8 +299,7 @@ void *QThreadPrivate::start(void *arg) User::SetCritical(User::EProcessCritical); #endif - pthread_once(¤t_thread_data_once, create_current_thread_data_key); - pthread_setspecific(current_thread_data_key, data); + set_thread_data(data); data->ref(); data->quitNow = false; |