diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2011-11-22 08:02:17 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-22 03:31:14 +0100 |
commit | d2c1adc6f9afc4dd1bab3c487bbde70f3b8f2e81 (patch) | |
tree | 633ef62d68173c588de1ff81e6e6ee25117f0b7f /src/declarative | |
parent | 0bf08af2b945f10f44561ffa0abd6f89b093b376 (diff) |
Emit destruction signal before child contexts are destroyed.
Verbatim comment from bug report:
When using a QtObject inside an item, and then we call a function
in the Component.onDestruction handler of that item, we get a
crash. This happens because the QDeclarativeContextData engine
has been invalidated before reaching
QDeclarativeExpressionPrivate::evalFunction.
Change code to emit the onDestruction signal before the child
contexts are invalidated.
Task-number: QTBUG-22535
Change-Id: Ic4983ae5fdf104ae977189c21dc202c9b02bc2bc
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qdeclarativecontext.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 1723603d29..50e2235768 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -529,14 +529,6 @@ QDeclarativeContextData::QDeclarativeContextData(QDeclarativeContext *ctxt) void QDeclarativeContextData::invalidate() { - while (childContexts) { - if (childContexts->ownedByParent) { - childContexts->destroy(); - } else { - childContexts->invalidate(); - } - } - while (componentAttached) { QDeclarativeComponentAttached *a = componentAttached; componentAttached = a->next; @@ -548,6 +540,14 @@ void QDeclarativeContextData::invalidate() emit a->destruction(); } + while (childContexts) { + if (childContexts->ownedByParent) { + childContexts->destroy(); + } else { + childContexts->invalidate(); + } + } + if (prevChild) { *prevChild = nextChild; if (nextChild) nextChild->prevChild = prevChild; |