diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-07-26 13:07:17 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-07-26 11:48:50 +0000 |
commit | b94889f49170e3d8df5b348d3f179445d892f232 (patch) | |
tree | 2ffedc1fbc8102741fc1535ffa99faaf8c110b93 | |
parent | d6c8721476607f22896785baa547a7551015f164 (diff) |
Fix QQuickStackViewPrivate::viewItemTransitionFinished()
~QQuickStackElement() emits QQuickStackViewAttached::removed(), which
may be used to modify the stack. Set the status first and make a copy
of the destroyable stack elements to exclude any modifications that may
happen during the loop.
Task-number: QTBUG-62153
Change-Id: I144acd693519e637b78f9a2d910e83da8f2d779e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickstackview_p.cpp | 8 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_stackview.qml | 13 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp index 3c983d6b..0b0f5ef5 100644 --- a/src/quicktemplates2/qquickstackview_p.cpp +++ b/src/quicktemplates2/qquickstackview_p.cpp @@ -278,9 +278,13 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition } if (transitioner->runningJobs.isEmpty()) { - qDeleteAll(removed); - removed.clear(); + // ~QQuickStackElement() emits QQuickStackViewAttached::removed(), which may be used + // to modify the stack. Set the status first and make a copy of the destroyable stack + // elements to exclude any modifications that may happen during the loop. (QTBUG-62153) setBusy(false); + QList<QQuickStackElement*> elements = removed; + removed.clear(); + qDeleteAll(elements); } removing.remove(element); diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 3328c84f..0f73b631 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -726,6 +726,19 @@ TestCase { compare(control.busy, false) } + function test_pushOnRemoved() { + var control = createTemporaryObject(stackView, testCase, { initialItem: component }) + verify(control) + + var item = control.push(component, StackView.Immediate) + verify(item) + + item.StackView.onRemoved.connect(function() { control.push(component, StackView.Immediate) } ) + + // don't crash (QTBUG-62153) + control.pop(StackView.Immediate) + } + Component { id: attachedItem Item { |