diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-17 09:54:04 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-17 09:54:04 +0100 |
commit | f52b95a96cc8f36f766635f9ddb6c95fa6b3c934 (patch) | |
tree | 0a74d23575ae74e93a7b2dedb7a03827c42e8266 /src/quicktemplates2/qquickstackview_p.cpp | |
parent | 2bd4f5cd587e258227c69b3124757d7b8e019c9f (diff) | |
parent | 7da5842647f75fd990f69f400f75d9b090e39306 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: Ieb9bcfba9651d646509afd065ce2389ef74448cc
Diffstat (limited to 'src/quicktemplates2/qquickstackview_p.cpp')
-rw-r--r-- | src/quicktemplates2/qquickstackview_p.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp index 7cb943a3..a280e31d 100644 --- a/src/quicktemplates2/qquickstackview_p.cpp +++ b/src/quicktemplates2/qquickstackview_p.cpp @@ -267,7 +267,11 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition element->setStatus(QQuickStackView::Active); } else if (element->status == QQuickStackView::Deactivating) { element->setStatus(QQuickStackView::Inactive); - element->setVisible(false); + QQuickStackElement *existingElement = element->item ? findElement(element->item) : nullptr; + // If a different element with the same item is found, + // do not call setVisible(false) since it needs to be visible. + if (!existingElement || element == existingElement) + element->setVisible(false); if (element->removal || element->isPendingRemoval()) removed += element; } @@ -275,11 +279,21 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition if (transitioner && transitioner->runningJobs.isEmpty()) { // ~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) + // elements to exclude any modifications that may happen during qDeleteAll(). (QTBUG-62153) setBusy(false); - QList<QQuickStackElement*> elements = removed; + QList<QQuickStackElement*> removedElements = removed; removed.clear(); - qDeleteAll(elements); + + for (QQuickStackElement *removedElement : qAsConst(removedElements)) { + // If an element with the same item is found in the active stack list, + // forget about the item so that we don't hide it. + if (removedElement->item && findElement(removedElement->item)) { + QQuickItemPrivate::get(removedElement->item)->removeItemChangeListener(removedElement, QQuickItemPrivate::Destroyed); + removedElement->item = nullptr; + } + } + + qDeleteAll(removedElements); } removing.remove(element); |