diff options
Diffstat (limited to 'tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp')
-rw-r--r-- | tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp b/tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp index 4d3eadbea4..1c50531d57 100644 --- a/tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp +++ b/tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp @@ -1,11 +1,12 @@ // Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtTest/qtest.h> #include <QQmlEngine> #include <QtQuick/qquickitem.h> #include <QtQuickTemplates2/private/qquickdeferredexecute_p_p.h> +#include <QQmlIncubator> class DeferredPropertyTester : public QObject { @@ -48,6 +49,7 @@ public: tst_qquickdeferred() : QQmlDataTest(QT_QMLTEST_DATADIR) {} private slots: void noSpuriousBinding(); + void abortedIncubation(); }; @@ -63,6 +65,25 @@ void tst_qquickdeferred::noSpuriousBinding() { root->setProperty("toggle", false); } +// QTBUG-116828 +// This test checks the case where we cancel incubation of a componet with a deferred property +// Components that have deferred properties should also provide an itemDestoryed method that +// that resets the deferred property to null to prevent issues with dangling pointers. +void tst_qquickdeferred::abortedIncubation() +{ + QQmlEngine engine; + QQmlIncubationController controller; + engine.setIncubationController(&controller); + + { + QQmlIncubator incubator; + QQmlComponent componet(&engine, testFileUrl("abortedIncubation.qml")); + componet.create(incubator); + controller.incubateFor(1); + incubator.clear(); // abort incubation (and dont crash) + } +} + QTEST_MAIN(tst_qquickdeferred) #include "tst_qquickdeferred.moc" |