diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-05-17 14:17:57 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-31 14:32:43 (GMT) |
commit | dfcc156a75f32f1147e95ce06e4262c102ee858e (patch) | |
tree | 2a3e217a86687ba6df990239215833279faa57b3 /tests | |
parent | df9491b302f6404ad2ccc6dc2eb3377176d994c6 (diff) | |
download | Qt-dfcc156a75f32f1147e95ce06e4262c102ee858e.zip Qt-dfcc156a75f32f1147e95ce06e4262c102ee858e.tar.gz Qt-dfcc156a75f32f1147e95ce06e4262c102ee858e.tar.bz2 |
Add a test in QObject.
Testing that slot from destroyed class are not called
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qobject/tst_qobject.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index d2307ee..4b926e4 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -135,7 +135,7 @@ private slots: void disconnectByMetaMethod(); void disconnectNotSignalMetaMethod(); void autoConnectionBehavior(); - + void baseDestroyed(); protected: }; @@ -3925,5 +3925,34 @@ void tst_QObject::autoConnectionBehavior() delete receiver; } +class BaseDestroyed : public QObject +{ Q_OBJECT + QList<QString> fooList; + bool destroyed; +public: + BaseDestroyed() : destroyed(false) + { fooList << "a" << "b"; } + ~BaseDestroyed() + { + QVERIFY(!destroyed); + destroyed = true; + } + +public slots: + void slotUseList() + { + QVERIFY(!destroyed); + fooList << "c" << "d"; + } +}; + +void tst_QObject::baseDestroyed() +{ + BaseDestroyed d; + connect(&d, SIGNAL(destroyed()), &d, SLOT(slotUseList())); + //When d goes out of scope, slotUseList should not be called as the BaseDestroyed has + // already been destroyed while ~QObject emit destroyed +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" |