summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2009-08-12 09:36:47 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-08-12 09:36:47 (GMT)
commite02769f81c0d7ca9585b2fd9ba58d901db513f8c (patch)
treecb33782a53331cd4d18c863f8b3180124ea304d4 /tests
parente81dd49a60f8058b8b142b1c6ed87526671abed9 (diff)
parent711f3691231ede6d8bf4e04f4dd8eb528655e115 (diff)
downloadQt-e02769f81c0d7ca9585b2fd9ba58d901db513f8c.zip
Qt-e02769f81c0d7ca9585b2fd9ba58d901db513f8c.tar.gz
Qt-e02769f81c0d7ca9585b2fd9ba58d901db513f8c.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qobject/tst_qobject.cpp18
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp15
2 files changed, 33 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"
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 6bc3aa0..58e5401 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -1593,6 +1593,21 @@ void tst_QSharedPointer::invalidConstructs_data()
<< "QObject *ptr = new QObject;\n"
"QWeakPointer<QObject> weak = ptr;\n" // this makes the object unmanaged
"QSharedPointer<QObject> shared(ptr);\n";
+
+#ifndef QT_NO_DEBUG
+ // this tests a Q_ASSERT, so it is only valid in debug mode
+ // the DerivedFromQObject destructor below creates a QWeakPointer from parent().
+ // parent() is not 0 in the current Qt implementation, but has started destruction,
+ // so the code should detect that issue
+ QTest::newRow("shared-pointer-from-qobject-in-destruction")
+ << &QTest::QExternalTest::tryRunFail
+ << "class DerivedFromQObject: public QObject { public:\n"
+ " DerivedFromQObject(QObject *parent): QObject(parent) {}\n"
+ " ~DerivedFromQObject() { QWeakPointer<QObject> weak = parent(); }\n"
+ "};\n"
+ "QObject obj;\n"
+ "new DerivedFromQObject(&obj);";
+#endif
}
void tst_QSharedPointer::invalidConstructs()