From fed8d73b0752b5f737082c534d39f350ca737a7b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 11 Aug 2009 14:15:30 +1000 Subject: Move the binding's "mePtr" into QmlAbstractBinding Now optimizations get deletion protection too. --- src/declarative/qml/qmlbinding.cpp | 17 +++++++++++------ src/declarative/qml/qmlbinding.h | 2 ++ src/declarative/qml/qmlbinding_p.h | 2 -- src/declarative/qml/qmlbindingoptimizations.cpp | 4 ++++ src/declarative/qml/qmlvme.cpp | 8 +++----- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index 7c5b366..45d20f4 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QML_DEFINE_NOCREATE_TYPE(QmlBinding); QmlBindingPrivate::QmlBindingPrivate() -: updating(false), enabled(false), mePtr(0) +: updating(false), enabled(false) { } @@ -75,9 +75,6 @@ QmlBinding::QmlBinding(const QString &str, QObject *obj, QmlContext *ctxt, QObje QmlBinding::~QmlBinding() { - Q_D(QmlBinding); - if(d->mePtr) - *(d->mePtr) = 0; } void QmlBinding::setTarget(const QmlMetaProperty &prop) @@ -153,12 +150,13 @@ void QmlBinding::setEnabled(bool e) setTrackChange(e); if (e) { - d->mePtr = 0; addToObject(d->property.object()); update(); } else { removeFromObject(); } + + QmlAbstractBinding::setEnabled(e); } int QmlBinding::propertyIndex() @@ -180,13 +178,15 @@ QString QmlBinding::expression() const } QmlAbstractBinding::QmlAbstractBinding() -: m_prevBinding(0), m_nextBinding(0) +: m_mePtr(0), m_prevBinding(0), m_nextBinding(0) { } QmlAbstractBinding::~QmlAbstractBinding() { removeFromObject(); + if (m_mePtr) + *m_mePtr = 0; } void QmlAbstractBinding::addToObject(QObject *object) @@ -217,4 +217,9 @@ QString QmlAbstractBinding::expression() const return QLatin1String(""); } +void QmlAbstractBinding::setEnabled(bool e) +{ + if (e) m_mePtr = 0; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h index ad25c16..63b8a15 100644 --- a/src/declarative/qml/qmlbinding.h +++ b/src/declarative/qml/qmlbinding.h @@ -73,7 +73,9 @@ public: private: friend class QmlDeclarativeData; friend class QmlMetaProperty; + friend class QmlVME; + QmlAbstractBinding **m_mePtr; QmlAbstractBinding **m_prevBinding; QmlAbstractBinding *m_nextBinding; }; diff --git a/src/declarative/qml/qmlbinding_p.h b/src/declarative/qml/qmlbinding_p.h index 767e6af..963e2c1 100644 --- a/src/declarative/qml/qmlbinding_p.h +++ b/src/declarative/qml/qmlbinding_p.h @@ -69,8 +69,6 @@ public: bool enabled:1; QmlMetaProperty property; - - QmlAbstractBinding **mePtr; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindingoptimizations.cpp b/src/declarative/qml/qmlbindingoptimizations.cpp index a10b1e3..e1f4a90 100644 --- a/src/declarative/qml/qmlbindingoptimizations.cpp +++ b/src/declarative/qml/qmlbindingoptimizations.cpp @@ -72,6 +72,8 @@ void QmlBinding_Id::setEnabled(bool e) } else { removeFromObject(); } + + QmlAbstractBinding::setEnabled(e); } int QmlBinding_Id::propertyIndex() @@ -147,6 +149,8 @@ void QmlBinding_ObjProperty::setEnabled(bool e) } else { removeFromObject(); } + + QmlAbstractBinding::setEnabled(e); } int QmlBinding_ObjProperty::propertyIndex() diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index fdfeddc..79b1d89 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -541,9 +541,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData QmlBinding *bind = new QmlBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, 0); bindValues.append(bind); - QmlBindingPrivate *p = - static_cast(QObjectPrivate::get(bind)); - p->mePtr = &bindValues.values[bindValues.count - 1]; + bind->m_mePtr = &bindValues.values[bindValues.count - 1]; bind->addToObject(target); bind->setTarget(mp); @@ -558,7 +556,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData new QmlBinding_Id(target, instr.assignIdOptBinding.property, ctxt, instr.assignIdOptBinding.id); bindValues.append(bind); - // ### Need a mePtr + bind->m_mePtr = &bindValues.values[bindValues.count - 1]; bind->addToObject(target); } break; @@ -573,7 +571,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData new QmlBinding_ObjProperty(target, instr.assignObjPropBinding.property, context, instr.assignObjPropBinding.contextIdx, instr.assignObjPropBinding.notifyIdx); bindValues.append(bind); - // ### Need a mePtr + bind->m_mePtr = &bindValues.values[bindValues.count - 1]; bind->addToObject(target); } break; -- cgit v0.12