Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.0
-
None
-
ca43c4121dde6c8f5d4eabfcf128ff6214996d54
Description
Timers are ticked by the animation system, and when a timer is about to fire, if another animation happens to stop, the timer will fire right away, which might result in leaving the state of the UI in a bad state.
This is a bit similar to applications calling QCoreApplication::processEvents() which is highly discouraged for the same reason. In this case, we can fix the issue by moving the timer triggering to be driven by a queued invoke rather than a direct connection.
import QtQuick 2.0 Rectangle { width: 360 height: 360 property bool bonus MouseArea { anchors.fill: parent onPositionChanged: { bonus = true for (var i=0; i<500; i++) r.x = Math.random() * 340 bonus = false } } Rectangle { id: r width: 20 height: 20 color: "blue" Behavior on x { NumberAnimation {} } } Timer { interval: 1 repeat: true running: true onTriggered: if (bonus) { console.warn("oops"); console.trace() } } }