diff options
Diffstat (limited to 'src/quicktemplates2/qquickstackview.cpp')
-rw-r--r-- | src/quicktemplates2/qquickstackview.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index d16d7b16..07c471b5 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -464,6 +464,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) @@ -484,6 +486,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()); |