aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2016-05-29 19:05:27 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-05-31 06:55:20 +0000
commite5c76615b72abcae628ca7561c16eab71f1d3a0e (patch)
tree6c4f9c1b3b8205681512a2d51f1e54569a762177
parentaf028f592b4934cbd92c42d94ee405f764edfb80 (diff)
Move dependent scripts to QV4::CompiledData::CompilationUnit
Change-Id: I85e8267ce4cd26ae83fe567357e1368658fdb43d Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp6
-rw-r--r--src/qml/compiler/qv4compileddata.cpp5
-rw-r--r--src/qml/compiler/qv4compileddata_p.h3
-rw-r--r--src/qml/qml/qqmlcompileddata.cpp3
-rw-r--r--src/qml/qml/qqmlcompiler_p.h2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp8
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<QQmlTypeData::ScriptReference> &scripts = typeData->resolvedScripts();
- compiledData->scripts.reserve(scripts.count());
+ QVector<QQmlScriptData *> 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 <private/qv4lookup_p.h>
#include <private/qv4regexpobject_p.h>
#include <private/qqmlpropertycache_p.h>
+#include <private/qqmltypeloader_p.h>
#endif
#include <private/qqmlirbuilder_p.h>
#include <QCoreApplication>
@@ -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<QQmlScriptData *> 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<int, TypeReference*> resolvedTypes;
- QList<QQmlScriptData *> scripts;
-
QQmlRefPointer<QV4::CompiledData::CompilationUnit> 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) {