summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-12-10 12:20:48 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:39 (GMT)
commit0cc309d2dd0469bc8997154455b91fba4697ccc5 (patch)
tree469a94ee2e295d364b826e6087e991a32ed67b98 /src/corelib/kernel
parent35e19b15241777d4339746a8b8d3ecca313cd3cf (diff)
downloadQt-0cc309d2dd0469bc8997154455b91fba4697ccc5.zip
Qt-0cc309d2dd0469bc8997154455b91fba4697ccc5.tar.gz
Qt-0cc309d2dd0469bc8997154455b91fba4697ccc5.tar.bz2
QPointer: thread safety
Fix a race condition between the destructor of QPointer and the destruction of the object living in a different thread. Task-number: QTBUG-16005 Reviewed-by: Joao
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index bb3bfab..57449bd 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -426,6 +426,8 @@ void QMetaObject::removeGuard(QObject **ptr)
if (!hash || hash->isEmpty())
return;
QMutexLocker locker(guardHashLock());
+ if (!*ptr) //check again, under the lock
+ return;
GuardHash::iterator it = hash->find(*ptr);
const GuardHash::iterator end = hash->end();
bool more = false; //if the QObject has more pointer attached to it.