From e5c76615b72abcae628ca7561c16eab71f1d3a0e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 29 May 2016 19:05:27 +0200 Subject: Move dependent scripts to QV4::CompiledData::CompilationUnit Change-Id: I85e8267ce4cd26ae83fe567357e1368658fdb43d Reviewed-by: Lars Knoll --- src/qml/compiler/qqmltypecompiler.cpp | 6 ++++-- src/qml/compiler/qv4compileddata.cpp | 5 +++++ src/qml/compiler/qv4compileddata_p.h | 3 +++ src/qml/qml/qqmlcompileddata.cpp | 3 --- src/qml/qml/qqmlcompiler_p.h | 2 -- src/qml/qml/qqmlobjectcreator.cpp | 8 ++++---- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index f8fe145392..19beb13e45 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -172,7 +172,8 @@ bool QQmlTypeCompiler::compile() // Collect imported scripts const QList &scripts = typeData->resolvedScripts(); - compiledData->scripts.reserve(scripts.count()); + QVector dependentScripts; + dependentScripts.reserve(scripts.count()); for (int scriptIndex = 0; scriptIndex < scripts.count(); ++scriptIndex) { const QQmlTypeData::ScriptReference &script = scripts.at(scriptIndex); @@ -188,7 +189,7 @@ bool QQmlTypeCompiler::compile() importCache->add(qualifier.toString(), scriptIndex, enclosingNamespace); QQmlScriptData *scriptData = script.script->scriptData(); scriptData->addref(); - compiledData->scripts << scriptData; + dependentScripts << scriptData; } // Resolve component boundaries and aliases @@ -242,6 +243,7 @@ bool QQmlTypeCompiler::compile() compiledData->compilationUnit = document->javaScriptCompilationUnit; compiledData->compilationUnit->propertyCaches = m_propertyCaches; compiledData->compilationUnit->importCache = importCache; + compiledData->compilationUnit->dependentScripts = dependentScripts; // Add to type registry of composites if (compiledData->compilationUnit->isCompositeType()) diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 728a4d5213..dc29d1b941 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #endif #include #include @@ -174,6 +175,10 @@ void CompilationUnit::unlink() propertyCaches.at(ii)->release(); propertyCaches.clear(); + for (int ii = 0; ii < dependentScripts.count(); ++ii) + dependentScripts.at(ii)->release(); + dependentScripts.clear(); + importCache = nullptr; engine = 0; diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 4417074a0e..8beb932fc8 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE class QQmlPropertyCache; class QQmlPropertyData; class QQmlTypeNameCache; +class QQmlScriptData; // The vector is indexed by QV4::CompiledData::Object index and the flag // indicates whether instantiation of the object requires a VME meta-object. @@ -691,6 +692,8 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount int totalParserStatusCount; // Number of instantiated types that are QQmlParserStatus subclasses int totalObjectCount; // Number of objects explicitly instantiated + QVector dependentScripts; + QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); void unlink(); diff --git a/src/qml/qml/qqmlcompileddata.cpp b/src/qml/qml/qqmlcompileddata.cpp index 405bf57448..b25792054c 100644 --- a/src/qml/qml/qqmlcompileddata.cpp +++ b/src/qml/qml/qqmlcompileddata.cpp @@ -84,9 +84,6 @@ QQmlCompiledData::~QQmlCompiledData() } qDeleteAll(resolvedTypes); resolvedTypes.clear(); - - for (int ii = 0; ii < scripts.count(); ++ii) - scripts.at(ii)->release(); } void QQmlCompiledData::clear() diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index 75a6835ae6..2c9e04d5e0 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -120,8 +120,6 @@ public: // map from name index QHash resolvedTypes; - QList scripts; - QQmlRefPointer compilationUnit; bool isInitialized() const { return hasEngine(); } diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 289ce4849d..dcd35bccad 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -183,12 +183,12 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI if (topLevelCreator) sharedState->allJavaScriptObjects = scope.alloc(compiledData->compilationUnit->totalObjectCount); - if (subComponentIndex == -1 && compiledData->scripts.count()) { - QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count())); + if (subComponentIndex == -1 && compiledData->compilationUnit->dependentScripts.count()) { + QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->compilationUnit->dependentScripts.count())); context->importedScripts.set(v4, scripts); QV4::ScopedValue v(scope); - for (int i = 0; i < compiledData->scripts.count(); ++i) { - QQmlScriptData *s = compiledData->scripts.at(i); + for (int i = 0; i < compiledData->compilationUnit->dependentScripts.count(); ++i) { + QQmlScriptData *s = compiledData->compilationUnit->dependentScripts.at(i); scripts->putIndexed(i, (v = s->scriptValueForContext(context))); } } else if (sharedState->creationContext) { -- cgit v1.2.3