aboutsummaryrefslogtreecommitdiffstats
path: root/src/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2015-08-28 13:35:19 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-08-28 13:36:16 +0000
commitb9e1bb07a97877d074267470409d1e6b0dd3a330 (patch)
tree4355caf95b2fc19dde45315d0d4ebfb1065052c9 /src/controls
parent11f463fc11fe799f439a1a12ca0ea1d9b1cf2a96 (diff)
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 <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/qquickstackview.cpp1
-rw-r--r--src/controls/qquickstackview_p.cpp8
-rw-r--r--src/controls/qquickstackview_p_p.h1
3 files changed, 8 insertions, 2 deletions
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<QQuickStackElement*> removals;
QStack<QQuickStackElement *> elements;
QQuickItemViewTransitioner *transitioner;
};