diff options
| author | Dmitrii Akshintsev <dmitrii.akshintsev@qt.io> | 2023-10-16 17:43:06 +0200 |
|---|---|---|
| committer | Dmitrii Akshintsev <dmitrii.akshintsev@qt.io> | 2023-10-24 18:44:55 +0200 |
| commit | c1320e7a35f3393d973126cc8e2c850e9377f4ab (patch) | |
| tree | 8e74cbe32eb5bf960ce093eef77105f3a7c1c21b /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 69fce1185f2ba3b474871e38b3b5b3161a9f72ee (diff) | |
Throw an exception in loadScopeObjectPropertyLookup when qmlScopeObject is null
When object is being destroyed, qmlScopeObject pointer is becoming null (I assume as part of the lookup invalidation?), causing nullptr dereferencing in the subsequent Init lookup stage.
This commit prevents it by introducing an "early exit" on the load stage.
Fixes: QTBUG-117866
Change-Id: Ifef1a0dd48a952f00f2c0d4d5015ec2f40b7f62a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 486a777fef..4854108b86 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -154,6 +154,7 @@ private slots: void notEqualsInt(); void notNotString(); void nullAccess(); + void nullAccessInsideSignalHandler(); void nullComparison(); void numbersInJsPrimitive(); void objectInVar(); @@ -3091,6 +3092,20 @@ void tst_QmlCppCodegen::nullAccess() QCOMPARE(object->property("height").toDouble(), 0.0); } +void tst_QmlCppCodegen::nullAccessInsideSignalHandler() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/nullAccessInsideSignalHandler.qml"_s)); + QVERIFY2(!component.isError(), component.errorString().toUtf8()); + QTest::ignoreMessage(QtWarningMsg, + "qrc:/qt/qml/TestTypes/nullAccessInsideSignalHandler.qml:15: ReferenceError: " + "text is not defined"); + QScopedPointer<QObject> object(component.create()); + QSignalSpy spy(object.data(), SIGNAL(say_hello())); + QTRY_VERIFY(spy.size() > 0); +} + + void tst_QmlCppCodegen::nullComparison() { QQmlEngine engine; |
