-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
4.7.3
-
None
This was observed with code from qt-qml:qtquick11 and HEAD at eb55d07febf858474d8755e31cb554a4b8fabcdc
Run the code below:
import QtQuick 1.1 Item { id: root width: 640 height: 480 Loader { id: loader anchors.centerIn: parent onLoaded: { if(status == Loader.Ready) { print("Loader.Ready") item.opacity = 1; item.opacityChanged.connect(item, handleOpacityChanged); } } } function handleOpacityChanged() { print("opacity: " + this.opacity + "\t state: " + root.state) if(root.state == "hide" && this.opacity == 0) { print("UNLOAD") // root.state = "" } } MouseArea { anchors.fill: parent onClicked: parent.state = (parent.state == "" ? "show" : "hide") } states: [ State { name: "" StateChangeScript { script: print("Applying '' state") } }, State { name: "show" StateChangeScript { script: print("Applying 'show' state") } PropertyChanges { target: loader; sourceComponent: blueRect } }, State { name: "hide" extend: "show" StateChangeScript { script: print("Applying 'hide' state") } PropertyChanges { target: loader.item; opacity: 0 } } ] Component { id: blueRect Rectangle { color: "blue" width: 100 height: 100 opacity: 0 Behavior on opacity { NumberAnimation { duration: 100 }} } } }
Clicking on the screen once should give output similar to this:
Loader.Ready
Applying 'show' state
Loader.Ready
opacity: 0.16 state: show
opacity: 0.32 state: show
opacity: 0.48 state: show
opacity: 0.64 state: show
opacity: 0.8 state: show
opacity: 0.96 state: show
opacity: 1 state: show
Except for the Loader.Ready status being notified twice despite fix for QTBUG-16319 being present the above looks correct.
Click on the screen a second time. This will result in output similar to this:
opacity: 0 state: hide <- (1) UNLOAD <- (3) opacity: 1 state: hide <- (2) Applying 'show' state Applying 'hide' state opacity: 0.84 state: hide opacity: 0.67 state: hide opacity: 0.52 state: hide opacity: 0.36 state: hide opacity: 0.199 state: hide opacity: 0.040 state: hide opacity: 0 state: hide UNLOAD
The issue is the stray opacity changes from fully opaque to fully transparent (1) and back to opaque (2) that happens just before the rectangle starts to fade out (manually marked in the log above). This results in "UNLOAD" being incorrectly printed too early (3), before the rectangle has actually faded out.