Use scope, not owner to look up enums in QQmlBoundSignal.
authorMichael Brasser <michael.brasser@nokia.com>
Tue, 3 Apr 2012 05:22:17 +0000 (15:22 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Apr 2012 07:22:28 +0000 (09:22 +0200)
With this, we no longer need to keep a pointer to the owner, so remove
it as well.

Change-Id: I0c38645b924bf5b0caadb46444cf6dd09abc1eb2
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
src/qml/qml/qqmlboundsignal.cpp
src/qml/qml/qqmlboundsignal_p.h
src/qml/qml/qqmlproperty.cpp
src/qml/qml/qqmlvme.cpp
src/quick/util/qquickconnections.cpp

index af63cb1..3afeb03 100644 (file)
@@ -204,10 +204,9 @@ QQmlAbstractBoundSignal::~QQmlAbstractBoundSignal()
     }
 }
 
-void QQmlAbstractBoundSignal::addToObject()
+void QQmlAbstractBoundSignal::addToObject(QObject *obj)
 {
     Q_ASSERT(!m_prevSignal);
-    QObject *obj = object();
     Q_ASSERT(obj);
 
     QQmlData *data = QQmlData::get(obj, true);
@@ -220,13 +219,15 @@ void QQmlAbstractBoundSignal::addToObject()
 
 QQmlBoundSignal::QQmlBoundSignal(QObject *scope, const QMetaMethod &signal,
                                QObject *owner)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0), m_owner(owner)
+: m_expression(0), m_params(0), m_scope(scope), m_signal(signal), m_paramsValid(false), m_isEvaluating(false)
 {
     // This is thread safe.  Although it may be updated by two threads, they
     // will both set it to the same value - so the worst thing that can happen
     // is that they both do the work to figure it out.  Boo hoo.
     if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
 
+    addToObject(owner);
+
     QQmlPropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
 }
 
@@ -347,7 +348,7 @@ QQmlBoundSignalParameters::QQmlBoundSignalParameters(const QMetaMethod &method,
                 if (scope == "Qt")
                     meta = &QObject::staticQtMetaObject;
                 else
-                    meta = static_cast<QQmlBoundSignal*>(parent)->object()->metaObject();
+                    meta = static_cast<QQmlBoundSignal*>(parent)->scope()->metaObject();
                 for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
                     QMetaEnum m = meta->enumerator(i);
                     if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {
index 2c24a24..c6ce875 100644 (file)
@@ -107,9 +107,10 @@ public:
     virtual int index() const = 0;
     virtual QQmlBoundSignalExpression *expression() const = 0;
     virtual QQmlBoundSignalExpression *setExpression(QQmlBoundSignalExpression *) = 0;
-    virtual QObject *object() = 0;
+    virtual QObject *scope() = 0;
 
-    void addToObject();
+protected:
+    void addToObject(QObject *owner);
 
 private:
     friend class QQmlData;
@@ -131,7 +132,7 @@ public:
 
     QQmlBoundSignalExpression *expression() const;
     QQmlBoundSignalExpression *setExpression(QQmlBoundSignalExpression *);
-    QObject *object() { return m_owner; }
+    QObject *scope() { return m_scope; }
 
     bool isEvaluating() const { return m_isEvaluating; }
 
@@ -140,11 +141,11 @@ protected:
 
 private:
     QQmlBoundSignalExpression *m_expression;
+    QQmlBoundSignalParameters *m_params;
+    QObject *m_scope;
     QMetaMethod m_signal;
     bool m_paramsValid : 1;
     bool m_isEvaluating : 1;
-    QQmlBoundSignalParameters *m_params;
-    QObject *m_owner;
 };
 
 QT_END_NAMESPACE
index 14f199c..88223dd 100644 (file)
@@ -972,7 +972,6 @@ QQmlPropertyPrivate::setSignalExpression(const QQmlProperty &that,
     if (expr) {
         QQmlBoundSignal *signal = new QQmlBoundSignal(that.d->object, that.method(), that.d->object);
         QQmlBoundSignalExpression *oldExpr = signal->setExpression(expr);
-        signal->addToObject();
         return oldExpr;
     } else {
         return 0;
index 259f618..21f07d9 100644 (file)
@@ -715,7 +715,6 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
             QQmlBoundSignalExpression *expr =
                 new QQmlBoundSignalExpression(CTXT, context, DATAS.at(instr.value), true, COMP->name, instr.line, instr.column);
             bs->setExpression(expr);
-            bs->addToObject();
         QML_END_INSTR(StoreSignal)
 
         QML_BEGIN_INSTR(StoreImportedScript)
index 2ba34a2..27b66ba 100644 (file)
@@ -283,7 +283,6 @@ void QQuickConnections::connectSignals()
             QQmlBoundSignalExpression *expression = ctxtdata ?
                 new QQmlBoundSignalExpression(ctxtdata, 0, script, true, location, line, column) : 0;
             signal->setExpression(expression);
-            signal->addToObject();
             d->boundsignals += signal;
         } else {
             if (!d->ignoreUnknownSignals)