aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickstackview_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-03-19 10:18:57 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2018-03-21 08:45:28 +0000
commitaceeec0a85cc50fec70e3142936332a3b09e7061 (patch)
tree059990158695a886d72bf18e25b5b30c489e2103 /src/quicktemplates2/qquickstackview_p.h
parentce5b33c350cb7aa4a649088d85e48be08b632b69 (diff)
Fix crash with StackView::initialItem
The following binding initialView: Qt.createComponent("blah.qml") works with QQC1 but crashes with QQC2 as soon as the garbage collector kicks in. In QQC1 StackView was implemented in a .qml file and the property was declared as property var initialItem For such declared properties the QML engine takes care of ensuring that the reference assigned is a strong reference towards the GC and it also tracks the life-time of the QObject in case it's explicitly deleted by somebody else. In QQC2 the property continues to be documented as "var" property, however it is implemented in C++ as QVariant property. The QVariant is not known to the GC at all and it also doesn't do life-cycle tracking. The C++ equivalent to "var" in QML is QJSValue, which is a strong reference and also ends up using a QPointer internally when holding a QObject. Task-number: QTBUG-67118 Change-Id: I43e473c7bf2c40f9843e9d50fe4fd805b54fd256 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickstackview_p.h')
-rw-r--r--src/quicktemplates2/qquickstackview_p.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h
index e347ba9d..ba6fe106 100644
--- a/src/quicktemplates2/qquickstackview_p.h
+++ b/src/quicktemplates2/qquickstackview_p.h
@@ -65,7 +65,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickStackView : public QQuickControl
Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged FINAL)
Q_PROPERTY(int depth READ depth NOTIFY depthChanged FINAL)
Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
- Q_PROPERTY(QVariant initialItem READ initialItem WRITE setInitialItem FINAL)
+ Q_PROPERTY(QJSValue initialItem READ initialItem WRITE setInitialItem FINAL)
Q_PROPERTY(QQuickTransition *popEnter READ popEnter WRITE setPopEnter NOTIFY popEnterChanged FINAL)
Q_PROPERTY(QQuickTransition *popExit READ popExit WRITE setPopExit NOTIFY popExitChanged FINAL)
Q_PROPERTY(QQuickTransition *pushEnter READ pushEnter WRITE setPushEnter NOTIFY pushEnterChanged FINAL)
@@ -93,8 +93,8 @@ public:
};
Q_ENUM(Status)
- QVariant initialItem() const;
- void setInitialItem(const QVariant &item);
+ QJSValue initialItem() const;
+ void setInitialItem(const QJSValue &item);
QQuickTransition *popEnter() const;
void setPopEnter(QQuickTransition *enter);