diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-07 14:12:04 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-07 14:12:04 (GMT) |
commit | 5f8ef6ac44e1db842003deeed6525eea70d8d83d (patch) | |
tree | 2b67b2abe7038e97fc72967a4882bf15c38d39a1 /src/corelib/thread | |
parent | d7dd967d4a4775e70d270dbcd0623ef07128d420 (diff) | |
parent | 62a2fe9092d3b6038a08f5c5a7faa4a863b84fdc (diff) | |
download | Qt-5f8ef6ac44e1db842003deeed6525eea70d8d83d.zip Qt-5f8ef6ac44e1db842003deeed6525eea70d8d83d.tar.gz Qt-5f8ef6ac44e1db842003deeed6525eea70d8d83d.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
qmake/generators/win32/msbuild_objectmodel.cpp
qmake/generators/win32/msbuild_objectmodel.h
qmake/generators/win32/msvc_objectmodel.cpp
qmake/generators/win32/msvc_vcxproj.cpp
src/corelib/arch/qatomic_arm.h
tests/auto/qglthreads/tst_qglthreads.cpp
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthreadstorage.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp index 88d73cc..2fc04f5 100644 --- a/src/corelib/thread/qthreadstorage.cpp +++ b/src/corelib/thread/qthreadstorage.cpp @@ -79,6 +79,21 @@ QThreadStorageData::QThreadStorageData(void (*func)(void *)) { QMutexLocker locker(mutex()); DestructorMap *destr = destructors(); + if (!destr) { + /* + the destructors vector has already been destroyed, yet a new + QThreadStorage is being allocated. this can only happen during global + destruction, at which point we assume that there is only one thread. + in order to keep QThreadStorage working, we need somewhere to store + the data, best place we have in this situation is at the tail of the + current thread's tls vector. the destructor is ignored, since we have + no where to store it, and no way to actually call it. + */ + QThreadData *data = QThreadData::current(); + id = data->tls.count(); + DEBUG_MSG("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func); + return; + } for (id = 0; id < destr->count(); id++) { if (destr->at(id) == 0) break; @@ -139,13 +154,15 @@ void **QThreadStorageData::set(void *p) data->thread); QMutexLocker locker(mutex()); - void (*destructor)(void *) = destructors()->value(id); + DestructorMap *destr = destructors(); + void (*destructor)(void *) = destr ? destr->value(id) : 0; locker.unlock(); void *q = value; value = 0; - destructor(q); + if (destructor) + destructor(q); } // store new data |