From b9e1bb07a97877d074267470409d1e6b0dd3a330 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Aug 2015 13:35:19 +0200 Subject: StackView: fix ownership issues QTBUG-47317 revealed that dynamically created items remained visible after popping, so they were not only kept visible but also weren't properly destroyed. The visibility issue had to be fixed so that "indestructible" (not owned by StackView) were hid. This change tackles the destruction part, and marks pop-exit items for removal so they get destroyed when transitions are finished. Now that the transitionable items are actually destroyed, a new problem was releaved. We must not delete transitionable items until both enter & exit transitions have been finished. If we did that, the finished() callback would not get called for the pop-exit transition and tst_StackView::test_transitions() would fail (yay). Change-Id: Ie2eedf99d0366820260776591ad1f8b5b68e2ec3 Task-number: QTBUG-47317 Reviewed-by: Mitch Curtis --- src/controls/qquickstackview.cpp | 1 + src/controls/qquickstackview_p.cpp | 8 ++++++-- src/controls/qquickstackview_p_p.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/controls/qquickstackview.cpp b/src/controls/qquickstackview.cpp index 39cca26c..1c09b6e8 100644 --- a/src/controls/qquickstackview.cpp +++ b/src/controls/qquickstackview.cpp @@ -269,6 +269,7 @@ QQuickStackView::~QQuickStackView() d->transitioner->setChangeListener(Q_NULLPTR); delete d->transitioner; } + qDeleteAll(d->removals); qDeleteAll(d->elements); } diff --git a/src/controls/qquickstackview_p.cpp b/src/controls/qquickstackview_p.cpp index 67cdde59..19ab6a39 100644 --- a/src/controls/qquickstackview_p.cpp +++ b/src/controls/qquickstackview_p.cpp @@ -389,6 +389,7 @@ void QQuickStackViewPrivate::ensureTransitioner() void QQuickStackViewPrivate::popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) { if (exit) { + exit->removal = true; exit->setStatus(QQuickStackView::Deactivating); exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true); } @@ -504,11 +505,14 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition if (element->item) element->item->setVisible(false); if (element->removal || element->isPendingRemoval()) - delete element; + removals += element; } - if (transitioner->runningJobs.isEmpty()) + if (transitioner->runningJobs.isEmpty()) { + qDeleteAll(removals); + removals.clear(); setBusy(false); + } } void QQuickStackViewPrivate::setBusy(bool busy) diff --git a/src/controls/qquickstackview_p_p.h b/src/controls/qquickstackview_p_p.h index 84ed9f35..7a185b7c 100644 --- a/src/controls/qquickstackview_p_p.h +++ b/src/controls/qquickstackview_p_p.h @@ -135,6 +135,7 @@ public: QVariant initialItem; QQuickItem *currentItem; + QList removals; QStack elements; QQuickItemViewTransitioner *transitioner; }; -- cgit v1.2.3