diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-06 16:23:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-07 12:44:05 +0100 |
commit | d5a96399cec189251d8ee3e82493aceec112fbd8 (patch) | |
tree | f87f262ff0e0a34744a7eea335ab09fe9c5bbec7 | |
parent | 85bab8c8dbe385520753bc77f36b8115be5a046e (diff) |
[new compiler] Fix memory management of newly created objects
It may happen that QML created objects get garbage collected, as they'll
be initially JS owned. We don't want that to happen, so we have to
protect them, similar to the qmlBindingWrappers array in the VME.
Change-Id: Iec541dccced46ac8aab447cd0558d22b84e3eac0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 02c922f2fb..38edfc0360 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1001,8 +1001,10 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope valueScope(v4); - QV4::ScopedObject jsScopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject)); - QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, new (v4->memoryManager) QV4::QmlBindingWrapper(v4->rootContext, jsScopeObject)); + QV4::ScopedValue scopeObjectProtector(valueScope, ddata ? ddata->jsWrapper.value() : 0); + Q_UNUSED(scopeObjectProtector); + QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject)); + QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, new (v4->memoryManager) QV4::QmlBindingWrapper(v4->rootContext, qmlScope)); QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context(); qSwap(_qmlContext, qmlContext); |