diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2012-05-11 12:01:41 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-24 12:52:43 +0200 |
commit | d2e557c2c2d7fcf3bf7c1676df3902e115986dc2 (patch) | |
tree | 65f47e443efa9635a2634880c01dc439817f9566 /src/qml/qml/qqmlboundsignal.cpp | |
parent | 0a3ff88f851771e52d119fab90c0254de6950585 (diff) |
Lazily create QMetaObjects
For internal QML built types, creating a metaobject each time is
just wasteful. Additionally, as the property caches were always
created from the intermediate QMetaObject, it was difficult to pass
information directly from the compiler to the property cache.
Change-Id: I769526b0edaaf16a86883f3065b75618b94e4077
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlboundsignal.cpp')
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 9a3ce65ad3..1a16c07a75 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -242,9 +242,9 @@ void QQmlAbstractBoundSignal::removeFromObject() } } -QQmlBoundSignal::QQmlBoundSignal(QObject *scope, const QMetaMethod &signal, - QObject *owner, QQmlEngine *engine) -: m_expression(0), m_params(0), m_scope(scope), m_index(signal.methodIndex()) +QQmlBoundSignal::QQmlBoundSignal(QObject *scope, int signal, QObject *owner, + QQmlEngine *engine) +: m_expression(0), m_params(0), m_scope(scope), m_index(signal) { setParamsValid(false); setIsEvaluating(false); @@ -257,11 +257,15 @@ QQmlBoundSignal::QQmlBoundSignal(QObject *scope, const QMetaMethod &signal, index refers to 'aSignal()', get the index of 'aSignal(int)'. This ensures that 'parameter' will be available from QML. */ - if (signal.attributes() & QMetaMethod::Cloned) { - do { + if (QQmlData::get(scope, false) && QQmlData::get(scope, false)->propertyCache) { + QQmlPropertyCache *cache = QQmlData::get(scope, false)->propertyCache; + while (cache->method(m_index)->isCloned()) + --m_index; + } else { + while (scope->metaObject()->method(m_index).attributes() & QMetaMethod::Cloned) --m_index; - } while (scope->metaObject()->method(m_index).attributes() & QMetaMethod::Cloned); } + QQmlNotifierEndpoint::connect(scope, m_index, engine); } @@ -328,9 +332,12 @@ void QQmlBoundSignal::subscriptionCallback(QQmlNotifierEndpoint *e, void **a) s->setIsEvaluating(true); if (!s->paramsValid()) { - QMetaMethod signal = s->m_scope->metaObject()->method(s->m_index); - if (!signal.parameterTypes().isEmpty()) + QList<QByteArray> names = QQmlPropertyCache::methodParameterNames(*s->m_scope, s->m_index); + if (!names.isEmpty()) { + QMetaMethod signal = s->m_scope->metaObject()->method(s->m_index); s->m_params = new QQmlBoundSignalParameters(signal, s); + } + s->setParamsValid(true); } |