aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickstackview.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-12-20 20:07:34 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-12-20 20:07:34 +0100
commit6e46d74b4d04fbf21ec7e57418ab5568f786b0e7 (patch)
tree8735964204723ad84af7a19b1d2eaca31c7d8f78 /src/quicktemplates2/qquickstackview.cpp
parent66cca16867594f27b6d9e44101f1bd34d165c8ac (diff)
parent8148e5338de3c8d307f758c9ffcf1f7309fd48bd (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/imports/controls/material/DialogButtonBox.qml src/imports/controls/universal/DialogButtonBox.qml Change-Id: I16cbf9912a3526783c21a6f30996f83fce9e02c3
Diffstat (limited to 'src/quicktemplates2/qquickstackview.cpp')
-rw-r--r--src/quicktemplates2/qquickstackview.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index b5bf0af7..0838e762 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -466,6 +466,8 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
\value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
\value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
+ \note Items that already exist in the stack are not pushed.
+
\sa initialItem, {Pushing Items}
*/
void QQuickStackView::push(QQmlV4Function *args)
@@ -486,6 +488,15 @@ void QQuickStackView::push(QQmlV4Function *args)
operation = static_cast<Operation>(lastArg->toInt32());
QList<QQuickStackElement *> elements = d->parseElements(args);
+ // Remove any items that are already in the stack, as they can't be in two places at once.
+ for (int i = 0; i < elements.size(); ) {
+ QQuickStackElement *element = elements.at(i);
+ if (element->item && d->findElement(element->item))
+ elements.removeAt(i);
+ else
+ ++i;
+ }
+
if (elements.isEmpty()) {
qmlInfo(this) << "push: nothing to push";
args->setReturnValue(QV4::Encode::null());