aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs/qmljslink.cpp
diff options
context:
space:
mode:
authorChristian Kamm <[email protected]>2011-11-21 14:51:03 +0100
committerChristian Kamm <[email protected]>2011-11-25 10:36:42 +0100
commit097850c842ce872d31716ddb528ebfad346475da (patch)
treefcbf558b7c37f1f4bb2bb3ea0bcf398d5a7f2b32 /src/libs/qmljs/qmljslink.cpp
parente2b0835b58aefdab91edda097c1180dae08058f6 (diff)
QmlJS: Speed up ValueOwner construction.
* Don't build all default values (including the global object) separately for each ValueOwner instance. * Instead, keep all global, immutable values in a single, shared instance. While refactoring, some cases where we *modified* the global object had to be removed: * C++ context properties no longer get injected into the global object, instead they now have their own scope just above the global one. * The Qt object's prototype no longer gets modified in Link. Instead, it's now a reference to the "Qt" object provided in a qmltypes file. * The whole concept of a function 'Activation' that could potentially affect the global object was removed. Change-Id: Id382faf965efa747fcc7a9b0bc2c90429d84d61b Reviewed-by: Leandro Melo <[email protected]>
Diffstat (limited to 'src/libs/qmljs/qmljslink.cpp')
-rw-r--r--src/libs/qmljs/qmljslink.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index 63ff773c330..69ec84d7683 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -154,8 +154,8 @@ Link::Link(const Snapshot &snapshot, const QStringList &importPaths, const Libra
d->valueOwner->cppQmlTypes().load(cppData.exportedTypes);
}
- // populate global object with context properties from C++
- ObjectValue *global = d->valueOwner->globalObject();
+ // build an object with the context properties from C++
+ ObjectValue *cppContextProperties = d->valueOwner->newObject(/* prototype = */ 0);
foreach (const ModelManagerInterface::CppData &cppData, cppDataHash) {
QHashIterator<QString, QString> it(cppData.contextProperties);
while (it.hasNext()) {
@@ -166,9 +166,10 @@ Link::Link(const Snapshot &snapshot, const QStringList &importPaths, const Libra
value = d->valueOwner->cppQmlTypes().objectByCppName(cppTypeName);
if (!value)
value = d->valueOwner->unknownValue();
- global->setMember(it.key(), value);
+ cppContextProperties->setMember(it.key(), value);
}
}
+ d->valueOwner->cppQmlTypes().setCppContextProperties(cppContextProperties);
}
}
@@ -205,11 +206,6 @@ Context::ImportsPerDocument LinkPrivate::linkImports()
// load library objects shipped with Creator
valueOwner->cppQmlTypes().load(CppQmlTypesLoader::defaultLibraryObjects);
- // the 'Qt' object is dumped even though it is not exported
- // it contains useful information, in particular on enums - add the
- // object as a prototype to our custom Qt object to offer these for completion
- const_cast<ObjectValue *>(valueOwner->qtObject())->setPrototype(valueOwner->cppQmlTypes().objectByCppName(QLatin1String("Qt")));
-
if (document) {
// do it on document first, to make sure import errors are shown
Imports *imports = new Imports(valueOwner);