aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlboundsignal.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-03-23 08:22:02 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-26 07:24:29 +0200
commit68ac4c57c46f72b4db16cf02ba67953c9cf4bdc4 (patch)
tree3a22ab063e86ca88004d103fa21c53ff82aae927 /src/qml/qml/qqmlboundsignal.cpp
parentfa3ef5376acc69b147718f49eddb842fdd5d2dd2 (diff)
Remove QObject parenting from QQmlAbstractBoundSignal.
Change-Id: If549cf57bbac18a986a2a0e63fdc76902d2dae43 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlboundsignal.cpp')
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index f8015a5d85..d666d9ceb0 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -89,42 +89,45 @@ private:
static int evaluateIdx = -1;
-QQmlAbstractBoundSignal::QQmlAbstractBoundSignal(QObject *parent)
-: QObject(parent)
+QQmlAbstractBoundSignal::QQmlAbstractBoundSignal()
+: m_prevSignal(0), m_nextSignal(0)
{
}
QQmlAbstractBoundSignal::~QQmlAbstractBoundSignal()
{
+ if (m_prevSignal) {
+ *m_prevSignal = m_nextSignal;
+ if (m_nextSignal) m_nextSignal->m_prevSignal = m_prevSignal;
+ m_prevSignal = 0;
+ m_nextSignal = 0;
+ }
}
-QQmlBoundSignal::QQmlBoundSignal(QObject *scope, const QMetaMethod &signal,
- QObject *parent)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0)
+void QQmlAbstractBoundSignal::addToObject()
{
- // 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();
+ Q_ASSERT(!m_prevSignal);
+ QObject *obj = object();
+ Q_ASSERT(obj);
- QQml_setParent_noEvent(this, parent);
- QQmlPropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
+ QQmlData *data = QQmlData::get(obj, true);
+
+ m_nextSignal = data->signalHandlers;
+ if (m_nextSignal) m_nextSignal->m_prevSignal = &m_nextSignal;
+ m_prevSignal = &data->signalHandlers;
+ data->signalHandlers = this;
}
-QQmlBoundSignal::QQmlBoundSignal(QQmlContext *ctxt, const QString &val,
- QObject *scope, const QMetaMethod &signal,
- QObject *parent)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0)
+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)
{
// 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();
- QQml_setParent_noEvent(this, parent);
QQmlPropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
-
- m_expression = new QQmlExpression(ctxt, scope, val);
}
QQmlBoundSignal::~QQmlBoundSignal()
@@ -244,7 +247,7 @@ QQmlBoundSignalParameters::QQmlBoundSignalParameters(const QMetaMethod &method,
if (scope == "Qt")
meta = &QObject::staticQtMetaObject;
else
- meta = parent->parent()->metaObject(); //### assumes parent->parent()
+ meta = static_cast<QQmlBoundSignal*>(parent)->object()->metaObject();
for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
QMetaEnum m = meta->enumerator(i);
if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {