From d444d21a517c45c0fda0bdf955cbda61e0088be6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 1 Feb 2016 09:33:38 +0100 Subject: Fix crash in Installer Framework when used with Qt 5.6 IFW uses QQmlV4Function in a QJSEngine environment, so there is no QML context. Up to commit cc98678f404cd49750076795f39b31bfa36c80c3 that would work. Let's fall back to the root context as scope if we don't have a qml context. Change-Id: Ib240746a95a0d16d61620f97abc31e4c74f36723 Reviewed-by: Lars Knoll --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 39bc8b2e5f..35824c6d00 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -190,6 +190,8 @@ private slots: void argumentEvaluationOrder(); + void v4FunctionWithoutQML(); + signals: void testSignal(); }; @@ -3799,6 +3801,30 @@ void tst_QJSEngine::argumentEvaluationOrder() } +class TestObject : public QObject +{ + Q_OBJECT +public: + TestObject() : called(false) {} + + bool called; + + Q_INVOKABLE void callMe(QQmlV4Function *) { + called = true; + } +}; + +void tst_QJSEngine::v4FunctionWithoutQML() +{ + TestObject obj; + QJSEngine engine; + QJSValue wrapper = engine.newQObject(&obj); + QQmlEngine::setObjectOwnership(&obj, QQmlEngine::CppOwnership); + QVERIFY(!obj.called); + wrapper.property("callMe").call(); + QVERIFY(obj.called); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3