aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcontext_p.h2
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp7
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp10
-rw-r--r--src/qml/qml/qqmltypeloader.cpp10
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp5
-rw-r--r--src/qml/qml/qqmlvme.cpp8
6 files changed, 28 insertions, 14 deletions
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index a5c3886af1..26048b0217 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -158,7 +158,7 @@ public:
QObject *contextObject;
// Any script blocks that exist on this context
- QList<QV4::PersistentValue> importedScripts;
+ QV4::PersistentValue importedScripts; // This is a JS Array
// Context base url
QUrl url;
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 832d9421c2..406826a6f6 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -192,11 +192,8 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has
if (hasProperty)
*hasProperty = true;
if (r.scriptIndex != -1) {
- int index = r.scriptIndex;
- if (index < context->importedScripts.count())
- return context->importedScripts.at(index).value();
- else
- return QV4::Primitive::undefinedValue().asReturnedValue();
+ QV4::ScopedObject scripts(scope, context->importedScripts);
+ return scripts->getIndexed(r.scriptIndex);
} else if (r.type) {
return QmlTypeWrapper::create(engine, scopeObject, r.type);
} else if (r.importNamespace) {
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 56776dcb82..8cce2db340 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -525,8 +525,14 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent)
context->setIdPropertyData(mapping);
if (subComponentIndex == -1) {
- foreach (QQmlScriptData *script, compiledData->scripts)
- context->importedScripts << script->scriptValueForContext(context);
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
+ QV4::Scope scope(v4);
+ QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count()));
+ for (int i = 0; i < compiledData->scripts.count(); ++i) {
+ QQmlScriptData *s = compiledData->scripts.at(i);
+ scripts->putIndexed(i, s->scriptValueForContext(context));
+ }
+ context->importedScripts = scripts;
} else if (parentContext) {
context->importedScripts = parentContext->importedScripts;
}
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 8d9c4ef2fe..1d2748de99 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2770,9 +2770,15 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620
}
- for (int ii = 0; ii < scripts.count(); ++ii) {
- ctxt->importedScripts << scripts.at(ii)->scriptData()->scriptValueForContext(ctxt);
+ QV4::ScopedObject scriptsArray(scope);
+ if (ctxt->importedScripts.isNullOrUndefined()) {
+ scriptsArray = v4->newArrayObject(scripts.count());
+ ctxt->importedScripts = scriptsArray;
+ } else {
+ scriptsArray = ctxt->importedScripts;
}
+ for (int ii = 0; ii < scripts.count(); ++ii)
+ scriptsArray->putIndexed(ii, scripts.at(ii)->scriptData()->scriptValueForContext(ctxt));
if (!hasEngine())
initialize(parentCtxt->engine);
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 3fb3d19270..f309d69136 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -202,9 +202,8 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro
if (r.type) {
return create(w->v8, object, r.type, w->mode);
} else if (r.scriptIndex != -1) {
- int index = r.scriptIndex;
- if (index < context->importedScripts.count())
- return context->importedScripts.at(index).value();
+ QV4::ScopedObject scripts(scope, context->importedScripts);
+ return scripts->getIndexed(r.scriptIndex);
} else if (r.importNamespace) {
return create(w->v8, object, context->imports, r.importNamespace);
}
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index c1c05fac11..b425b84a53 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -791,7 +791,13 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QML_END_INSTR(StoreSignal)
QML_BEGIN_INSTR(StoreImportedScript)
- CTXT->importedScripts << SCRIPTS.at(instr.value)->scriptValueForContext(CTXT);
+ QV4::Scope scope(v4);
+ QV4::ScopedObject scripts(scope, CTXT->importedScripts.value());
+ if (!scripts) {
+ scripts = v4->newArrayObject();
+ CTXT->importedScripts = scripts;
+ }
+ scripts->putIndexed(instr.value, SCRIPTS.at(instr.value)->scriptValueForContext(CTXT));
QML_END_INSTR(StoreImportedScript)
QML_BEGIN_INSTR(StoreScriptString)