aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlimport.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-08-14 11:44:49 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-28 04:32:48 +0200
commit70a2c0491d66aa05f9e9e67f8a845f4df84da857 (patch)
tree08d7828cfb6950926e1176ee420d5e15dedd9817 /src/qml/qml/qqmlimport.cpp
parent3912bbaceab166eb116447311eb16453e4f26edf (diff)
Refactor singleton type registration code
Previously each singleton type was registered as an implicit separate import. This commit changes the code so that these types are treated just like any other type in the registration sense. It also ensures that singleton types are instantiated per-engine. Change-Id: I5c81c4ca5bf65210f7125d74a62a282a21838068 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlimport.cpp')
-rw-r--r--src/qml/qml/qqmlimport.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 739492b3d3..63f49a2a03 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -290,23 +290,15 @@ QUrl QQmlImports::baseUrl() const
return d->baseUrl;
}
-void QQmlImports::populateCache(QQmlTypeNameCache *cache, QQmlEngine *engine) const
+void QQmlImports::populateCache(QQmlTypeNameCache *cache) const
{
const QQmlImportNamespace &set = d->unqualifiedset;
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportNamespace::Import *import = set.imports.at(ii);
QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion);
- if (module)
+ if (module) {
cache->m_anonymousImports.append(QQmlTypeModuleVersion(module, import->minversion));
-
- QQmlMetaType::SingletonType singletonType = QQmlMetaType::singletonType(import->uri, import->majversion,
- import->minversion);
- if (singletonType.script || singletonType.qobject) {
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
- QQmlMetaType::SingletonInstance *apiInstance = ep->singletonTypeInstance(singletonType);
-
- cache->addSingletonType(singletonType.typeName, apiInstance);
}
}
@@ -321,16 +313,6 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache, QQmlEngine *engine) co
QQmlTypeNameCache::Import &typeimport = cache->m_namedImports[set.prefix];
typeimport.modules.append(QQmlTypeModuleVersion(module, import->minversion));
}
-
- QQmlMetaType::SingletonType singletonType = QQmlMetaType::singletonType(import->uri, import->majversion,
- import->minversion);
- if (singletonType.script || singletonType.qobject) {
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
- QQmlMetaType::SingletonInstance *apiInstance = ep->singletonTypeInstance(singletonType);
-
- cache->add(set.prefix);
- cache->addSingletonType(singletonType.typeName, apiInstance, set.prefix);
- }
}
}
}