aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-12 09:31:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-12 15:10:04 +0100
commitf844c588fc1e34e6269ba9636c2cb2706e94457b (patch)
tree5d3804108dac6508898218b4ae085d8d03da63cb /tests
parent9cc72b43e09c5abd94bb8d13e5b3fbe4d674a726 (diff)
Don't crash when a signal/slot connection outlives the engine
In the test case in the bug, the signal was emitted from the QApplication destructor (somewhere from the qpa plugin when the platform windows were destroyed) Task-number: QTBUG-37351 Change-Id: Ieec59e12be10bab1428743b80eecdf22ef9d8bf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 6e0ef16ce7..b6c564a6ce 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -257,6 +257,7 @@ private slots:
void include();
void includeRemoteSuccess();
void signalHandlers();
+ void qtbug_37351();
void doubleEvaluate();
void forInLoop();
void nonNotifyable();
@@ -6087,6 +6088,27 @@ void tst_qqmlecmascript::signalHandlers()
delete o;
}
+void tst_qqmlecmascript::qtbug_37351()
+{
+ MyTypeObject signalEmitter;
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import Qt.test 1.0; import QtQml 2.0;\nQtObject {\n"
+ " Component.onCompleted: {\n"
+ " testObject.action.connect(function() { print('dont crash'); });"
+ " }\n"
+ "}", QUrl());
+
+ engine.rootContext()->setContextProperty("testObject", &signalEmitter);
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ }
+ signalEmitter.doAction();
+ // Don't crash
+}
+
void tst_qqmlecmascript::qtbug_10696()
{
QQmlComponent component(&engine, testFileUrl("qtbug_10696.qml"));