diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2012-07-24 11:41:50 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-08 07:55:19 +0200 |
commit | 6ebf215fdaf2d757ab90ae4d46c4b938e978e2dc (patch) | |
tree | 515da352f1cc4d5567b6d93f0b19952b2e27d705 /src/qml/qml/qqmlimport.cpp | |
parent | 92562eacbc3c614a83a734f1108ed7df02415eae (diff) |
Add type name to singleton (module api) implementations.
This change renames the previous module api implementation
to singleton types.
When a singleton type is registered, a type name must be provided
that is used when accessing the API from QML. This makes the
implementation more consistent with the rest of QML.
Task-number: QTBUG-26549
Change-Id: Iab0bb1ccf516bd3ae20aee562a64d22976e0aecd
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlimport.cpp')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index e7133992d9..6475621bee 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -299,6 +299,15 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache, QQmlEngine *engine) co QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion); 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); + } } for (QQmlImportNamespace *ns = d->qualifiedSets.first(); ns; ns = d->qualifiedSets.next(ns)) { @@ -313,12 +322,14 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache, QQmlEngine *engine) co typeimport.modules.append(QQmlTypeModuleVersion(module, import->minversion)); } - QQmlMetaType::ModuleApi moduleApi = QQmlMetaType::moduleApi(import->uri, import->majversion, + QQmlMetaType::SingletonType singletonType = QQmlMetaType::singletonType(import->uri, import->majversion, import->minversion); - if (moduleApi.script || moduleApi.qobject) { - QQmlTypeNameCache::Import &import = cache->m_namedImports[set.prefix]; + if (singletonType.script || singletonType.qobject) { QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - import.moduleApi = ep->moduleApiInstance(moduleApi); + QQmlMetaType::SingletonInstance *apiInstance = ep->singletonTypeInstance(singletonType); + + cache->add(set.prefix); + cache->addSingletonType(singletonType.typeName, apiInstance, set.prefix); } } } |