aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp11
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);