From a75c0cb5a7de3b205bd612ecd5e49b4ecc225ecd Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 3 May 2015 17:02:55 +0200 Subject: [PATCH] Get rid of QQmlAbstractBoundSignal QQmlBoundSignal is the only class inheriting from it, so we might as well get rid of the abstract base class. Change-Id: I1b59a5d30d9a6ff1111e54f47530687b47f39d70 Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmlenginedebugservice.cpp | 2 +- src/qml/qml/qqmlboundsignal.cpp | 54 +++++++++------------ src/qml/qml/qqmlboundsignal_p.h | 37 +++++--------- src/qml/qml/qqmldata_p.h | 4 +- src/qml/qml/qqmlengine.cpp | 4 +- src/qml/qml/qqmlproperty.cpp | 4 +- 6 files changed, 42 insertions(+), 63 deletions(-) diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp index 20a9b083b..7db3d3636 100644 --- a/src/qml/debugger/qqmlenginedebugservice.cpp +++ b/src/qml/debugger/qqmlenginedebugservice.cpp @@ -278,7 +278,7 @@ void QQmlEngineDebugService::buildObjectDump(QDataStream &message, QQmlData *ddata = QQmlData::get(object); if (ddata && ddata->signalHandlers) { - QQmlAbstractBoundSignal *signalHandler = ddata->signalHandlers; + QQmlBoundSignal *signalHandler = ddata->signalHandlers; while (signalHandler) { QQmlObjectProperty prop; diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 77dccf6f0..813040c25 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -279,17 +279,36 @@ void QQmlBoundSignalExpression::evaluate(void **a) //////////////////////////////////////////////////////////////////////// -QQmlAbstractBoundSignal::QQmlAbstractBoundSignal() -: m_prevSignal(0), m_nextSignal(0) + +/*! \internal + \a signal MUST be in the signal index range (see QObjectPrivate::signalIndex()). + This is different from QMetaMethod::methodIndex(). +*/ +QQmlBoundSignal::QQmlBoundSignal(QObject *target, int signal, QObject *owner, + QQmlEngine *engine) + : m_prevSignal(0), m_nextSignal(0), + m_expression(0), m_index(signal), m_isEvaluating(false) { + addToObject(owner); + setCallback(QQmlNotifierEndpoint::QQmlBoundSignal); + + /* + If this is a cloned method, connect to the 'original'. For example, + for the signal 'void aSignal(int parameter = 0)', if the method + index refers to 'aSignal()', get the index of 'aSignal(int)'. + This ensures that 'parameter' will be available from QML. + */ + m_index = QQmlPropertyCache::originalClone(target, m_index); + QQmlNotifierEndpoint::connect(target, m_index, engine); } -QQmlAbstractBoundSignal::~QQmlAbstractBoundSignal() +QQmlBoundSignal::~QQmlBoundSignal() { removeFromObject(); + m_expression = 0; } -void QQmlAbstractBoundSignal::addToObject(QObject *obj) +void QQmlBoundSignal::addToObject(QObject *obj) { Q_ASSERT(!m_prevSignal); Q_ASSERT(obj); @@ -302,7 +321,7 @@ void QQmlAbstractBoundSignal::addToObject(QObject *obj) data->signalHandlers = this; } -void QQmlAbstractBoundSignal::removeFromObject() +void QQmlBoundSignal::removeFromObject() { if (m_prevSignal) { *m_prevSignal = m_nextSignal; @@ -312,31 +331,6 @@ 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 *target, int signal, QObject *owner, - QQmlEngine *engine) -: m_expression(0), m_index(signal), m_isEvaluating(false) -{ - addToObject(owner); - setCallback(QQmlNotifierEndpoint::QQmlBoundSignal); - - /* - If this is a cloned method, connect to the 'original'. For example, - for the signal 'void aSignal(int parameter = 0)', if the method - index refers to 'aSignal()', get the index of 'aSignal(int)'. - This ensures that 'parameter' will be available from QML. - */ - m_index = QQmlPropertyCache::originalClone(target, m_index); - QQmlNotifierEndpoint::connect(target, m_index, engine); -} - -QQmlBoundSignal::~QQmlBoundSignal() -{ - m_expression = 0; -} /*! Returns the signal index in the range returned by QObjectPrivate::signalIndex(). diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index bc30b25d6..0a139875d 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -118,37 +118,14 @@ private: QFlagPointer m_extra; }; -class Q_QML_PRIVATE_EXPORT QQmlAbstractBoundSignal -{ -public: - QQmlAbstractBoundSignal(); - virtual ~QQmlAbstractBoundSignal(); - - virtual int index() const = 0; - virtual QQmlBoundSignalExpression *expression() const = 0; - virtual QQmlBoundSignalExpressionPointer setExpression(QQmlBoundSignalExpression *) = 0; - virtual QQmlBoundSignalExpressionPointer takeExpression(QQmlBoundSignalExpression *) = 0; - virtual bool isEvaluating() const = 0; - - void removeFromObject(); -protected: - void addToObject(QObject *owner); - -private: - friend class QQmlData; - friend class QQmlPropertyPrivate; - friend class QQmlEngineDebugService; - QQmlAbstractBoundSignal **m_prevSignal; - QQmlAbstractBoundSignal *m_nextSignal; -}; - -class Q_QML_PRIVATE_EXPORT QQmlBoundSignal : public QQmlAbstractBoundSignal, - public QQmlNotifierEndpoint +class Q_QML_PRIVATE_EXPORT QQmlBoundSignal : public QQmlNotifierEndpoint { public: QQmlBoundSignal(QObject *target, int signal, QObject *owner, QQmlEngine *engine); virtual ~QQmlBoundSignal(); + void removeFromObject(); + int index() const; QQmlBoundSignalExpression *expression() const; @@ -159,6 +136,14 @@ public: private: friend void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **); + friend class QQmlPropertyPrivate; + friend class QQmlData; + friend class QQmlEngineDebugService; + + void addToObject(QObject *owner); + + QQmlBoundSignal **m_prevSignal; + QQmlBoundSignal *m_nextSignal; QQmlBoundSignalExpressionPointer m_expression; int m_index; diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 93c7bc6df..3d2a76693 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -59,7 +59,7 @@ class QQmlEngine; class QQmlGuardImpl; class QQmlCompiledData; class QQmlAbstractBinding; -class QQmlAbstractBoundSignal; +class QQmlBoundSignal; class QQmlContext; class QQmlPropertyCache; class QQmlContextData; @@ -151,7 +151,7 @@ public: QQmlContextData *outerContext; QQmlAbstractBinding *bindings; - QQmlAbstractBoundSignal *signalHandlers; + QQmlBoundSignal *signalHandlers; // Linked list for QQmlContext::contextObjects QQmlData *nextContextObject; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 45f37ead9..a1b512bba 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1668,7 +1668,7 @@ void QQmlData::destroyed(QObject *object) deferredData = 0; } - QQmlAbstractBoundSignal *signalHandler = signalHandlers; + QQmlBoundSignal *signalHandler = signalHandlers; while (signalHandler) { if (signalHandler->isEvaluating()) { // The object is being deleted during signal handler evaluation. @@ -1699,7 +1699,7 @@ void QQmlData::destroyed(QObject *object) "%s", object, qPrintable(locationString)); } - QQmlAbstractBoundSignal *next = signalHandler->m_nextSignal; + QQmlBoundSignal *next = signalHandler->m_nextSignal; signalHandler->m_prevSignal = 0; signalHandler->m_nextSignal = 0; delete signalHandler; diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 0181d138a..eec631736 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -888,7 +888,7 @@ QQmlPropertyPrivate::signalExpression(const QQmlProperty &that) if (!data) return 0; - QQmlAbstractBoundSignal *signalHandler = data->signalHandlers; + QQmlBoundSignal *signalHandler = data->signalHandlers; while (signalHandler && signalHandler->index() != QQmlPropertyPrivate::get(that)->signalIndex()) signalHandler = signalHandler->m_nextSignal; @@ -936,7 +936,7 @@ QQmlPropertyPrivate::takeSignalExpression(const QQmlProperty &that, if (!data) return 0; - QQmlAbstractBoundSignal *signalHandler = data->signalHandlers; + QQmlBoundSignal *signalHandler = data->signalHandlers; while (signalHandler && signalHandler->index() != QQmlPropertyPrivate::get(that)->signalIndex()) signalHandler = signalHandler->m_nextSignal; -- 2.34.1