diff options
author | Michael Brasser <michael.brasser@live.com> | 2014-07-23 12:43:38 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2014-08-07 21:36:27 +0200 |
commit | b42c8c4de293af0b6e9c0691daa835939b54d4e1 (patch) | |
tree | 0df0321298af530c95d085063500799d82f7aaa4 /src/qml/qml/qqmltypewrapper.cpp | |
parent | ee616b3905106a3eedef9ee964ab283ef45c7dbc (diff) |
Accelerate property lookups for C++-based QObject singletons.
Change-Id: Icbdf06a077014db5dd57cba42f84591433ec4196
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmltypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmltypewrapper.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 53afd36437..0ae3e31ec0 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -75,6 +75,17 @@ bool QmlTypeWrapper::isSingleton() const return d()->type && d()->type->isSingleton(); } +QObject* QmlTypeWrapper::singletonObject() const +{ + if (!isSingleton()) + return 0; + + QQmlEngine *e = d()->v8->engine(); + QQmlType::SingletonInstanceInfo *siinfo = d()->type->singletonInstanceInfo(); + siinfo->init(e); + return siinfo->qobjectApi(e); +} + QVariant QmlTypeWrapper::toVariant() const { if (d()->type && d()->type->isSingleton()) { |