diff options
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 17 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmldeclarativedata_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 17 |
4 files changed, 25 insertions, 15 deletions
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 38cbcfa..1afe945 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -55,7 +55,8 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() : parent(0), engine(0), isInternal(false), propertyNames(0), notifyIndex(-1), - highPriorityCount(0), imports(0), expressions(0), idValues(0), idValueCount(0) + highPriorityCount(0), imports(0), expressions(0), contextObjects(0), + idValues(0), idValueCount(0) { } @@ -283,14 +284,14 @@ QmlContext::~QmlContext() expression = nextExpression; } - for (int ii = 0; ii < d->contextObjects.count(); ++ii) { - QObjectPrivate *p = QObjectPrivate::get(d->contextObjects.at(ii)); - QmlDeclarativeData *data = - static_cast<QmlDeclarativeData *>(p->declarativeData); - if(data) - data->context = 0; + while (d->contextObjects) { + QmlDeclarativeData *co = d->contextObjects; + d->contextObjects = d->contextObjects->nextContextObject; + + co->context = 0; + co->nextContextObject = 0; + co->prevContextObject = 0; } - d->contextObjects.clear(); delete [] d->idValues; diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index c8d0b2d..a70d5db 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -106,7 +106,7 @@ public: QmlAbstractExpression *expressions; - QObjectList contextObjects; + QmlDeclarativeData *contextObjects; struct ContextGuard : public QGuard<QObject> { diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h index aa82f32..a6020d7 100644 --- a/src/declarative/qml/qmldeclarativedata_p.h +++ b/src/declarative/qml/qmldeclarativedata_p.h @@ -72,6 +72,10 @@ public: QmlContext *context; QmlAbstractBinding *bindings; + // Linked list for QmlContext::contextObjects + QmlDeclarativeData *nextContextObject; + QmlDeclarativeData**prevContextObject; + int bindingBitsSize; quint32 *bindingBits; bool hasBindingBit(int) const; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 06743cc..88a8c45 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -440,7 +440,8 @@ void QmlEngine::setContextForObject(QObject *object, QmlContext *context) } data->context = context; - context->d_func()->contextObjects.append(object); + data->nextContextObject = context->d_func()->contextObjects; + data->prevContextObject = &context->d_func()->contextObjects; } void qmlExecuteDeferred(QObject *object) @@ -493,9 +494,10 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre } QmlDeclarativeData::QmlDeclarativeData(QmlContext *ctxt) -: context(ctxt), bindings(0), bindingBitsSize(0), bindingBits(0), - outerContext(0), lineNumber(0), columnNumber(0), deferredComponent(0), - deferredIdx(0), attachedProperties(0), propertyCache(0) +: context(ctxt), bindings(0), nextContextObject(0), prevContextObject(0), + bindingBitsSize(0), bindingBits(0), outerContext(0), lineNumber(0), + columnNumber(0), deferredComponent(0), deferredIdx(0), attachedProperties(0), + propertyCache(0) { } @@ -505,8 +507,11 @@ void QmlDeclarativeData::destroyed(QObject *object) deferredComponent->release(); if (attachedProperties) delete attachedProperties; - if (context) - static_cast<QmlContextPrivate *>(QObjectPrivate::get(context))->contextObjects.removeAll(object); + + if (nextContextObject) + nextContextObject->prevContextObject = prevContextObject; + if (prevContextObject) + *prevContextObject = nextContextObject; QmlAbstractBinding *binding = bindings; while (binding) { |