summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-12 08:33:33 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-12 08:40:45 (GMT)
commitb3b2bc3f190d80e30b968648dd91048df67b8a50 (patch)
tree65b0d075d2be2addb55aa7baf6af58a8154abbe6 /tests/auto
parent62aa09a47cc226518d42f1b3b2337fdcb440da33 (diff)
downloadQt-b3b2bc3f190d80e30b968648dd91048df67b8a50.zip
Qt-b3b2bc3f190d80e30b968648dd91048df67b8a50.tar.gz
Qt-b3b2bc3f190d80e30b968648dd91048df67b8a50.tar.bz2
Possible Dead lock in the destructor of QObject
The problem was that we were locking a mutex that was global to thread to remove posted events associated with a QObject from the posted event list. We were also immediately deleting those events. If that triggers the deletion of another QObject, you would then trigger a dead-lock. Task-number: 259514 Reviewed-by: brad Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qobject/tst_qobject.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 2823c71..bb00a0b 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -119,6 +119,7 @@ private slots:
void qobjectConstCast();
void uniqConnection();
void interfaceIid();
+ void deleteQObjectWhenDeletingEvent();
protected:
};
@@ -2898,5 +2899,22 @@ void tst_QObject::interfaceIid()
QByteArray());
}
+void tst_QObject::deleteQObjectWhenDeletingEvent()
+{
+ //this is related to task 259514
+ //before the fix this used to dead lock when the QObject from the event was destroyed
+
+ struct MyEvent : public QEvent
+ {
+ MyEvent() : QEvent(QEvent::User) { }
+ QObject obj;
+ };
+
+ QObject o;
+ QApplication::postEvent(&o, new MyEvent);
+ QCoreApplication::removePostedEvents(&o); // here you would get a deadlock
+}
+
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"