diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-03-19 10:18:57 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-03-21 08:45:28 +0000 |
commit | aceeec0a85cc50fec70e3142936332a3b09e7061 (patch) | |
tree | 059990158695a886d72bf18e25b5b30c489e2103 /src/quicktemplates2/qquickstackview_p_p.h | |
parent | ce5b33c350cb7aa4a649088d85e48be08b632b69 (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_p.h')
-rw-r--r-- | src/quicktemplates2/qquickstackview_p_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h index d86f35cd..7f1b77b1 100644 --- a/src/quicktemplates2/qquickstackview_p_p.h +++ b/src/quicktemplates2/qquickstackview_p_p.h @@ -96,7 +96,7 @@ public: bool busy; QString operation; - QVariant initialItem; + QJSValue initialItem; QQuickItem *currentItem; QSet<QQuickStackElement*> removing; QList<QQuickStackElement*> removed; |