aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quickcontrols/deferred')
-rw-r--r--tests/auto/quickcontrols/deferred/CMakeLists.txt6
-rw-r--r--tests/auto/quickcontrols/deferred/data/abortedIncubation.qml171
-rw-r--r--tests/auto/quickcontrols/deferred/tst_qquickdeferred.cpp23
3 files changed, 199 insertions, 1 deletions
diff --git a/tests/auto/quickcontrols/deferred/CMakeLists.txt b/tests/auto/quickcontrols/deferred/CMakeLists.txt
index 58ae1653e6..07df0b6d3d 100644
--- a/tests/auto/quickcontrols/deferred/CMakeLists.txt
+++ b/tests/auto/quickcontrols/deferred/CMakeLists.txt
@@ -1,3 +1,9 @@
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qquickdeferred LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
data/*)
diff --git a/tests/auto/quickcontrols/deferred/data/abortedIncubation.qml b/tests/auto/quickcontrols/deferred/data/abortedIncubation.qml
new file mode 100644
index 0000000000..6cd4c1c04a
--- /dev/null
+++ b/tests/auto/quickcontrols/deferred/data/abortedIncubation.qml
@@ -0,0 +1,171 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Dialogs
+import QtQuick.Controls.Basic
+
+ApplicationWindow {
+ id: appWindow
+
+ // QQuickDeferredPointer<QQuickItem> background;
+ background: Rectangle {
+ id: backgroundRect
+ color: "black"
+ }
+
+ // internal property handle
+ ColorDialog {
+ id: colorDialog
+ options: ColorDialog.DontUseNativeDialog
+ }
+
+ // internal property upButton
+ // internal property textField
+ FolderDialog {
+ id: folderDialog
+ options: FolderDialog.DontUseNativeDialog
+ }
+
+ // indicator property of AbstractButton
+ Button {
+ id: basicButton
+ indicator: Rectangle {
+ id: basicButtonIndicator
+ color: "pink"
+ }
+ }
+
+ Dial {
+ id: dial
+ // QQuickDeferredPointer<QQuickItem> handle;
+ handle: Item {
+ Rectangle {
+ id: dialRect
+ }
+ }
+ }
+
+ GroupBox {
+ id: groupBox
+ // QQuickDeferredPointer<QQuickItem> label;
+ label: Label {
+ id: groupBoxLabel
+ text: "yo"
+ }
+ }
+
+ Label {
+ id: label
+ text: "yo2"
+ background: Rectangle {
+ id: labelBackground
+ color: "green"
+ }
+ }
+
+ Menu {
+ id: menu
+
+ MenuItem {
+ id: menuItem
+ text: "New..."
+ arrow: Rectangle {
+ id: menuItemArrow
+ color: "pink"
+ }
+ }
+ }
+
+ ScrollBar {
+ id: scrollbar
+ }
+
+ SpinBox {
+ id: spinBox
+
+ up.indicator: Rectangle {
+ id: spinBoxUpIndicator
+ color: "pink"
+ }
+ down.indicator: Rectangle {
+ id: spinBoxDownIndicator
+ color: "blue"
+ }
+ }
+
+ Control {
+ id: genericControl
+ background: Rectangle {
+ id: genericControlBackground
+ color: "red"
+ }
+ contentItem: Canvas {
+ id: genericControlContentItem
+ }
+ }
+
+ ComboBox {
+ id: comboBox
+ model: ["foo", "bar"]
+
+ popup: Popup {
+ id: comboBoxPopup
+ contentItem: ListView {
+ ScrollBar.vertical: ScrollBar {}
+ }
+ }
+ indicator: Item {
+ id: emptyPopupItem
+ }
+ }
+
+ Slider {
+ id: slider
+ // QQuickDeferredPointer<QQuickItem> handle;
+ handle: Item {
+ Rectangle {
+ id: rect
+ }
+ }
+ }
+
+ RangeSlider {
+ id: rangeSlider
+ first.handle: Item {
+ Rectangle {
+ id: rangeSliderRect1
+ }
+ }
+ second.handle: Item {
+ Rectangle {
+ id: rangeSliderRect2
+ }
+ }
+ }
+
+ TextArea {
+ id: textArea
+ background: Rectangle {
+ id: textAreaBackground
+ color: "pink"
+ }
+ }
+
+ TextField {
+ id: textField
+ background: Rectangle {
+ id: textFieldBackground
+ color: "pink"
+ }
+ }
+
+ TabBar {
+ id: bar
+ TabButton {
+ text: qsTr("One")
+ }
+ TabButton {
+ text: qsTr("Two")
+ }
+ }
+}
+
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"