diff options
author | Michael Brasser <mbrasser@ford.com> | 2018-01-08 13:33:27 -0600 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-10-26 05:20:41 +0000 |
commit | 475c74a9926efcd968572563e678988e53804603 (patch) | |
tree | 57675cdf22c34a098f82ecb54baf01be5dcbd810 /src/qml/qml/qqmlcomponent.cpp | |
parent | 33d85e20037e83d10b8ce66f8745f00d84baccd8 (diff) |
Hold internal reference to incubator object while incubating
Task-number: QTBUG-53111
Change-Id: Ifaef6a855914d79155f8028b0de7ccca3c9a00f5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlcomponent.cpp')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index a67c5c4a2b..5ed3cc5d6a 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1132,22 +1132,23 @@ class QQmlComponentIncubator : public QQmlIncubator public: QQmlComponentIncubator(QV4::Heap::QmlIncubatorObject *inc, IncubationMode mode) : QQmlIncubator(mode) - , incubatorObject(inc) - {} + { + incubatorObject.set(inc->internalClass->engine, inc); + } void statusChanged(Status s) override { - QV4::Scope scope(incubatorObject->internalClass->engine); - QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject); + QV4::Scope scope(incubatorObject.engine()); + QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>()); i->statusChanged(s); } void setInitialState(QObject *o) override { - QV4::Scope scope(incubatorObject->internalClass->engine); - QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject); + QV4::Scope scope(incubatorObject.engine()); + QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>()); i->setInitialState(o); } - QV4::Heap::QmlIncubatorObject *incubatorObject; + QV4::PersistentValue incubatorObject; // keep a strong internal reference while incubating }; @@ -1571,6 +1572,9 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error); } } + + if (s != QQmlIncubator::Loading) + d()->incubator->incubatorObject.clear(); } #undef INITIALPROPERTIES_SOURCE |