diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-01 10:49:04 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-08-01 10:49:04 +0200 |
commit | 6e70fa5ee8d0433dbb0d42378bce10db18b05fab (patch) | |
tree | 3030b30daa13790e1f5bdf540383fc7c06b849fc /src/qml | |
parent | 77d6aef4063a9bf18074609fc32d3ffeed88617c (diff) | |
parent | 8b88e37bf79a53eb0cb34226aacb25ad9b01d7cf (diff) |
Merge "Merge remote-tracking branch 'origin/5.3' into dev" into refs/staging/dev
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmldata_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 27 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator_p.h | 1 |
4 files changed, 25 insertions, 9 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index e2636a57c3..b8ada7ceaf 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -277,12 +277,12 @@ bool QQmlTypeCompiler::compile() if (qmlType->parserStatusCast() != -1) ++parserStatusCount; } + ++objectCount; if (typeRef->component) { bindingCount += typeRef->component->totalBindingsCount; parserStatusCount += typeRef->component->totalParserStatusCount; objectCount += typeRef->component->totalObjectCount; - } else - ++objectCount; + } } } diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 93060e97fb..e3e1434746 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -239,7 +239,7 @@ bool QQmlData::wasDeleted(QObject *object) return true; QObjectPrivate *priv = QObjectPrivate::get(object); - if (priv->wasDeleted) + if (!priv || priv->wasDeleted) return true; return priv->declarativeData && diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 9501b705ba..72920f1ae2 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -96,6 +96,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompile sharedState->allCreatedBindings.allocate(compiledData->totalBindingsCount); sharedState->allParserStatusCallbacks.allocate(compiledData->totalParserStatusCount); sharedState->allCreatedObjects.allocate(compiledData->totalObjectCount); + sharedState->allJavaScriptObjects = 0; sharedState->creationContext = creationContext; sharedState->rootContext = 0; @@ -195,6 +196,13 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI sharedState->rootContext->isRootObjectInCreation = true; } + QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); + QV4::Scope scope(v4); + + Q_ASSERT(sharedState->allJavaScriptObjects || topLevelCreator); + if (topLevelCreator) + sharedState->allJavaScriptObjects = scope.alloc(compiledData->totalObjectCount); + QVector<QQmlContextData::ObjectIdMapping> mapping(objectIndexToId.count()); for (QHash<int, int>::ConstIterator it = objectIndexToId.constBegin(), end = objectIndexToId.constEnd(); it != end; ++it) { @@ -208,8 +216,6 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI context->setIdPropertyData(mapping); if (subComponentIndex == -1) { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); - QV4::Scope scope(v4); QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count())); context->importedScripts = scripts; for (int i = 0; i < compiledData->scripts.count(); ++i) { @@ -230,6 +236,9 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI ddata->compiledData->addref(); } + if (topLevelCreator) + sharedState->allJavaScriptObjects = 0; + phase = CreatingObjectsPhase2; if (interrupt && interrupt->shouldInterrupt()) @@ -258,8 +267,11 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance) QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope valueScope(v4); - QV4::ScopedValue scopeObjectProtector(valueScope, declarativeData->jsWrapper.value()); - Q_UNUSED(scopeObjectProtector); + + Q_ASSERT(topLevelCreator); + Q_ASSERT(!sharedState->allJavaScriptObjects); + sharedState->allJavaScriptObjects = valueScope.alloc(compiledData->totalObjectCount); + QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject)); QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(v4->rootContext, qmlScope)); QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context(); @@ -1159,9 +1171,12 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo qSwap(_scopeObject, scopeObject); QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); + + Q_ASSERT(sharedState->allJavaScriptObjects); + QV4::ValueRef ref = QV4::ValueRef::fromRawValue(sharedState->allJavaScriptObjects++); + ref = QV4::QObjectWrapper::wrap(v4, instance); + QV4::Scope valueScope(v4); - 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, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(v4->rootContext, qmlScope)); QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context(); diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index ad2d67624f..fb4d71d054 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -64,6 +64,7 @@ struct QQmlObjectCreatorSharedState : public QSharedData QFiniteStack<QQmlAbstractBinding*> allCreatedBindings; QFiniteStack<QQmlParserStatus*> allParserStatusCallbacks; QFiniteStack<QObject*> allCreatedObjects; + QV4::Value *allJavaScriptObjects; // pointer to vector on JS stack to reference JS wrappers during creation phase. QQmlComponentAttached *componentAttached; QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks; QQmlVmeProfiler profiler; |