From d8639db8eefd738f195203bd1266819462749cd7 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 13 Dec 2019 17:54:32 -0400 Subject: [PATCH] Fix HSwipeView binding loop --- src/qml/Base/HSwipeView.qml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qml/Base/HSwipeView.qml b/src/qml/Base/HSwipeView.qml index 93b0dd88..62d872d6 100644 --- a/src/qml/Base/HSwipeView.qml +++ b/src/qml/Base/HSwipeView.qml @@ -1,14 +1,22 @@ +import QtQuick 2.12 import QtQuick.Controls 2.12 SwipeView { - currentIndex: window.getState(this, "currentIndex", defaultIndex) - onCurrentIndexChanged: window.saveState(this) + Component.onCompleted: if (! changed) { + setCurrentIndex(window.getState(this, "currentIndex", defaultIndex)) + saveEnabled = true + } + + onCurrentIndexChanged: if (saveEnabled) window.saveState(this) property string saveName: "" property var saveId: "ALL" property var saveProperties: ["currentIndex"] + // Prevent onCurrentIndexChanged from running before Component.onCompleted + property bool saveEnabled: false + property int defaultIndex: 0 property bool changed: currentIndex !== defaultIndex