Get rid of QQmlAbstractBoundSignal
authorLars Knoll <lars.knoll@theqtcompany.com>
Sun, 3 May 2015 15:02:55 +0000 (17:02 +0200)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Thu, 18 Jun 2015 04:10:48 +0000 (04:10 +0000)
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 <simon.hausmann@theqtcompany.com>
src/qml/debugger/qqmlenginedebugservice.cpp
src/qml/qml/qqmlboundsignal.cpp
src/qml/qml/qqmlboundsignal_p.h
src/qml/qml/qqmldata_p.h
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmlproperty.cpp

index 20a9b083bb818591bef665f577a4479f9d344b21..7db3d3636195d9e674189a60f4fe8fe4a16f431a 100644 (file)
@@ -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;
index 77dccf6f0469423d19231e1f4cdba2154bcfad79..813040c253381708fd7cebca328705502b05fb1d 100644 (file)
@@ -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().
index bc30b25d6a06cfdfe5ca392b0283448a306eb3fb..0a139875db66790d61048aa5e72da0817462e035 100644 (file)
@@ -118,37 +118,14 @@ private:
     QFlagPointer<ExtraData> 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;
index 93c7bc6df062b3750d5174d113041d67f598a2d7..3d2a76693a09cc0a965ab3bf2e76539cc4f0faeb 100644 (file)
@@ -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;
index 45f37ead93bc6249ad37b1b142358fc9d2907c74..a1b512bbae4c6a8120aba8978c8fd8e38e60ce34 100644 (file)
@@ -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;
index 0181d138af5a2df3666a8dcf6ba9aade9d7d1fc3..eec6317364fb457c320ca88c63cbe1d7dd1017c2 100644 (file)
@@ -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;