diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-02-01 09:33:38 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2016-02-02 13:08:51 +0000 |
commit | d444d21a517c45c0fda0bdf955cbda61e0088be6 (patch) | |
tree | 5db991b718ccbeea40e18eeb51528024daf6a7c7 /tests/auto/qml | |
parent | 1d417a7bfa99695db7d8bf6b28a5141bf97e96cc (diff) |
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 <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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" |