diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-17 14:42:05 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-17 15:45:45 +0100 |
commit | acf1298e21abd2fb12d8364c593fbbff345374bc (patch) | |
tree | 30533bedc74cbf5f55ba767c34daa694e746c865 /src/qml/qml/qqmlobjectcreator.cpp | |
parent | 3f362cdf9304afeed06081cd5abfcaf6aaabe19e (diff) |
Fix crash with lazy binding initialization and compile time calculated dependencies
During lazy binding initialization we may execute bindings where we calculated
dependencies to the context object at compile time. In order to register those
dependencies, the contet object needs to be set in the QQmlContextData.
This patch makes sure to set it before setting up the bindings.
Change-Id: Iacd360140cd9c389487bda82f6a7e6cc3a44c154
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index d0852bbef2..0825b8ec53 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -213,7 +213,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI context->importedScripts = sharedState->creationContext->importedScripts; } - QObject *instance = createInstance(objectToCreate, parent); + QObject *instance = createInstance(objectToCreate, parent, /*isContextObject*/true); if (instance) { QQmlData *ddata = QQmlData::get(instance); Q_ASSERT(ddata); @@ -221,8 +221,6 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI ddata->compiledData->release(); ddata->compiledData = compiledData; ddata->compiledData->addref(); - - context->contextObject = instance; } Q_QML_VME_PROFILE(sharedState->profiler, stop()); @@ -1014,7 +1012,7 @@ void QQmlObjectCreator::recordError(const QV4::CompiledData::Location &location, errors << error; } -QObject *QQmlObjectCreator::createInstance(int index, QObject *parent) +QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isContextObject) { ActiveOCRestorer ocRestorer(this, QQmlEnginePrivate::get(engine)); @@ -1111,6 +1109,11 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent) if (idEntry != objectIndexToId.constEnd()) context->setIdProperty(idEntry.value(), instance); + // Register the context object in the context early on in order for pending binding + // initialization to find it available. + if (isContextObject) + context->contextObject = instance; + QBitArray bindingsToSkip; if (customParser) { QHash<int, QQmlCompiledData::CustomParserData>::ConstIterator entry = compiledData->customParserData.find(index); |