Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.15.0
-
None
-
Ubuntu 20.04
Description
The states system in QML seems to behave differently in Qt5.15.0 than in previous version.
Let's say we define 2 states "BLUE" and "GREEN", setting the when property respectively to
blue and !blue where blue is a boolean property.
import QtQuick 2.15 import QtQuick.Window 2.15 Window { visible: true width: 640 height: 480 Rectangle { id: rec property bool blue: true width: 200 height: 80 color: "red" anchors.centerIn: parent onStateChanged: console.log("state =", state) states: [ State { name: "BLUE" when: rec.blue PropertyChanges { target: rec color: "blue" } }, State { name: "GREEN" when: !rec.blue PropertyChanges { target: rec color: "green" } } ] } Timer { running: true repeat: true interval: 1000 onTriggered: rec.blue = !rec.blue } }
If you update the blue property from true to false, the item state will change from BLUE to GREEN, but then, if you update it from false to true, the state will first change to default state "" and finally BLUE state.
OUTPUT: qml: state = BLUE qml: state = GREEN qml: state = qml: state = BLUE qml: state = GREEN qml: state = qml: state = BLUE qml: state = GREEN
The return to default state is unexpected and would break a transition between GREEN and BLUE state.