summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptextqobject
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-08-03 11:44:17 +0200
commite92293cf46337e8f533908846b9e80b9ae286d6a (patch)
tree46f0e33b8a688ecde73a2a8cbf8ceefb14ef0e85 /tests/auto/qscriptextqobject
parentc7d269eab57982517d6fcebea051ad3d8ec955a3 (diff)
Don't crash if queued signal handler no longer exists
Cherry-picked from qt5/script commit c89315da2e836fe67c4228cfb73c25a68b0a3a95 Task-number: QTBUG-26261 Change-Id: I24544e2f8c36eaf19c65d9a30affd1f3e05b52bb Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/qscriptextqobject')
-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 cb27878ca8..11468f370e 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;
@@ -3643,5 +3644,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"