summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-06-25 15:46:36 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-26 13:58:12 +0200
commitc89315da2e836fe67c4228cfb73c25a68b0a3a95 (patch)
treefa1f5a143273e8d30728ed69887e0ce3134a2949 /tests
parent4e95f21a77cb77cecda50865b3ce75104d7729b5 (diff)
downloadqtscript-c89315da2e836fe67c4228cfb73c25a68b0a3a95.tar.gz
Don't crash if queued signal handler no longer exists
Task-number: QTBUG-26261 Change-Id: Ie269c56c0336b1c937d4ec551f913ae7537d0338 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index d4c4caf..bbf72ad 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -585,6 +585,7 @@ private slots:
void nestedObjectAsSlotArgument_data();
void nestedObjectAsSlotArgument();
void propertyAccessThroughActivationObject();
+ void connectionRemovedAfterQueuedCall();
private:
QScriptEngine *m_engine;
@@ -3672,5 +3673,37 @@ void tst_QScriptExtQObject::propertyAccessThroughActivationObject()
m_engine->popContext();
}
+class SignalEmitterThread : public QThread
+{
+public:
+ SignalEmitterThread(MyQObject *sender)
+ : m_sender(sender)
+ { }
+
+ void run()
+ { m_sender->emitMySignal(); }
+
+private:
+ MyQObject *m_sender;
+};
+
+// QTBUG-26261
+void tst_QScriptExtQObject::connectionRemovedAfterQueuedCall()
+{
+ QVERIFY(m_engine->evaluate("var pass = true; function onMySignal() { pass = false; }").isUndefined());
+ QVERIFY(m_engine->evaluate("myObject.mySignal.connect(onMySignal)").isUndefined());
+
+ SignalEmitterThread thread(m_myObject);
+ QVERIFY(m_myObject->thread() != &thread); // Premise for queued call
+ thread.start();
+ QVERIFY(thread.wait());
+
+ QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(onMySignal)").isUndefined());
+ // Should not crash
+ QCoreApplication::processEvents();
+
+ QVERIFY(m_engine->evaluate("pass").toBool());
+}
+
QTEST_MAIN(tst_QScriptExtQObject)
#include "tst_qscriptextqobject.moc"