From c421281a0291fd48c616a6e37315364ce0553c0f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Sun, 3 Jun 2012 21:10:32 +0200 Subject: Adapt to connection-related changes in qtbase The QQmlData hooks signalEmitted() and receivers() now receive the index in the signal index range (i.e., excluding non-signal methods). This was done to avoid Q(Meta)Object having to compute the class's method offset; the signal offset should be sufficient for everyone. This required adapting QQmlNotifier, QQmlBoundSignal, QQmlPropertyCache and friends to use the signal index range whenever a property's notify signal is involved in the internal connection lists and property captures. Using the signal index range also reduces the memory used for NotifyList::notifies, since useless entries for non-signal methods will no longer be created. Change-Id: I62872fbea5a1f829b8b03bae3fc1e6acd84cf886 Reviewed-by: Aaron Kennedy --- src/qml/qml/qqmlboundsignal.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/qml/qml/qqmlboundsignal.cpp') diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 7ed723048f..3713de9270 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -41,6 +41,7 @@ #include "qqmlboundsignal_p.h" +#include #include #include "qqmlengine_p.h" #include "qqmlexpression_p.h" @@ -242,6 +243,10 @@ void QQmlAbstractBoundSignal::removeFromObject() } } +/*! \internal + \a signal MUST be in the signal index range (see QObjectPrivate::signalIndex()). + This is different from QMetaMethod::methodIndex(). +*/ QQmlBoundSignal::QQmlBoundSignal(QObject *scope, int signal, QObject *owner, QQmlEngine *engine) : m_expression(0), m_params(0), m_scope(scope), m_index(signal) @@ -259,10 +264,10 @@ QQmlBoundSignal::QQmlBoundSignal(QObject *scope, int signal, QObject *owner, */ if (QQmlData::get(scope, false) && QQmlData::get(scope, false)->propertyCache) { QQmlPropertyCache *cache = QQmlData::get(scope, false)->propertyCache; - while (cache->method(m_index)->isCloned()) + while (cache->signal(m_index)->isCloned()) --m_index; } else { - while (scope->metaObject()->method(m_index).attributes() & QMetaMethod::Cloned) + while (QMetaObjectPrivate::signal(scope->metaObject(), m_index).attributes() & QMetaMethod::Cloned) --m_index; } @@ -275,6 +280,10 @@ QQmlBoundSignal::~QQmlBoundSignal() delete m_params; } +/*! + Returns the signal index in the range returned by QObjectPrivate::signalIndex(). + This is different from QMetaMethod::methodIndex(). +*/ int QQmlBoundSignal::index() const { return m_index; @@ -325,16 +334,16 @@ void QQmlBoundSignal_callback(QQmlNotifierEndpoint *e, void **a) return; if (QQmlDebugService::isDebuggingEnabled()) - QV8DebugService::instance()->signalEmitted(QString::fromLatin1(s->m_scope->metaObject()->method(s->m_index).methodSignature())); + QV8DebugService::instance()->signalEmitted(QString::fromLatin1(QMetaObjectPrivate::signal(s->m_scope->metaObject(), s->m_index).methodSignature())); QQmlHandlingSignalProfiler prof(s->m_expression); s->setIsEvaluating(true); if (!s->paramsValid()) { - QList names = QQmlPropertyCache::methodParameterNames(*s->m_scope, s->m_index); + QList names = QQmlPropertyCache::signalParameterNames(*s->m_scope, s->m_index); if (!names.isEmpty()) { - QMetaMethod signal = s->m_scope->metaObject()->method(s->m_index); + QMetaMethod signal = QMetaObjectPrivate::signal(s->m_scope->metaObject(), s->m_index); s->m_params = new QQmlBoundSignalParameters(signal, s); } -- cgit v1.2.3