Move the target object into the base class
authorLars Knoll <lars.knoll@theqtcompany.com>
Thu, 16 Apr 2015 20:15:27 +0000 (22:15 +0200)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Fri, 5 Jun 2015 08:37:28 +0000 (08:37 +0000)
Change-Id: I912d7665b49c8e9b2d38e78bfcfc4b3d39ca7459
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/qml/qqmlabstractbinding_p.h
src/qml/qml/qqmlbinding.cpp
src/qml/qml/qqmlbinding_p.h
src/qml/qml/qqmlvaluetypeproxybinding.cpp
src/qml/qml/qqmlvaluetypeproxybinding_p.h

index d4cb4e0..aa76c9a 100644 (file)
@@ -77,7 +77,7 @@ public:
 
     // Should return the object for the binding.  Should return this object even if the
     // binding is not enabled or added to the object.
-    virtual QObject *targetObject() const = 0;
+    QObject *targetObject() const { return m_target.data(); }
 
     virtual void setEnabled(bool e, QQmlPropertyPrivate::WriteFlags f = QQmlPropertyPrivate::DontRemoveBinding) = 0;
 
@@ -121,6 +121,9 @@ private:
     // This saves a compiler-generated pointer to a compiler-generated vTable, and thus reduces
     // the binding object size by sizeof(void*).
     qintptr m_nextBindingPtr;
+
+protected:
+    QFlagPointer<QObject> m_target;
 };
 
 QQmlAbstractBinding::Pointer
index 24818cb..ec9ac91 100644 (file)
@@ -270,11 +270,6 @@ QString QQmlBinding::expression() const
     return v->toQStringNoThrow();
 }
 
-QObject *QQmlBinding::targetObject() const
-{
-    return *m_target;
-}
-
 int QQmlBinding::targetPropertyIndex() const
 {
     return m_index;
index 2d09c0f..69d434a 100644 (file)
@@ -84,7 +84,6 @@ public:
     // Inherited from QQmlAbstractBinding
     virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags flags = QQmlPropertyPrivate::DontRemoveBinding);
     virtual QString expression() const;
-    virtual QObject *targetObject() const;
     virtual int targetPropertyIndex() const;
     void update(QQmlPropertyPrivate::WriteFlags flags = QQmlPropertyPrivate::DontRemoveBinding);
 
@@ -107,7 +106,6 @@ private:
     inline void setEnabledFlag(bool);
     QQmlPropertyData getPropertyData() const;
 
-    QFlagPointer<QObject> m_target;
     int m_index;
 };
 
index f0457d2..a12699f 100644 (file)
 QT_BEGIN_NAMESPACE
 
 QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, int index)
-: QQmlAbstractBinding(ValueTypeProxy), m_object(o), m_index(index), m_bindings(0)
+    : QQmlAbstractBinding(ValueTypeProxy),
+      m_targetIndex(index),
+      m_bindings(0)
 {
+    m_target = o;
 }
 
 QQmlValueTypeProxyBinding::~QQmlValueTypeProxyBinding()
@@ -103,12 +106,7 @@ void QQmlValueTypeProxyBinding::removeBindings(quint32 mask)
 
 int QQmlValueTypeProxyBinding::targetPropertyIndex() const
 {
-    return m_index;
-}
-
-QObject *QQmlValueTypeProxyBinding::targetObject() const
-{
-    return m_object;
+    return m_targetIndex;
 }
 
 QT_END_NAMESPACE
index c73c944..6e61837 100644 (file)
@@ -59,15 +59,13 @@ public:
 
     virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags);
     virtual int targetPropertyIndex() const;
-    virtual QObject *targetObject() const;
 
 protected:
     ~QQmlValueTypeProxyBinding();
 
 private:
     friend class QQmlAbstractBinding;
-    QObject *m_object;
-    int m_index;
+    int m_targetIndex;
     QQmlAbstractBinding *m_bindings;
 };