aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.h
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/qqml.h
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/qqml.h')
-rw-r--r--src/qml/qml/qqml.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index a10ed0c5e8..105274d3e3 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -441,22 +441,25 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi
uri, versionMajor, versionMinor, typeName,
- callback, 0, 0
+ callback, 0, 0, 0, 0
};
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);
}
+static const int CurrentSingletonTypeRegistrationVersion = 2;
template <typename T>
inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName,
QObject *(*callback)(QQmlEngine *, QJSEngine *))
{
+ QML_GETTYPENAMES
+
QQmlPrivate::RegisterSingletonType api = {
- 1,
+ CurrentSingletonTypeRegistrationVersion,
uri, versionMajor, versionMinor, typeName,
- 0, callback, &T::staticMetaObject
+ 0, callback, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0
};
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);