Details
-
Bug
-
Resolution: Done
-
P4: Low
-
4.7.4, 5.0.0
-
None
-
Windows
-
d489f2f6549a86b3949004d1c8ec68487fc2adb7
Description
When Behavior depends on a property which in turn depends on other parameters, the Behavior gets called whenever the other parameters change, even when the property itself doesn't change.
In the uploaded example, Behavior depends on a boolean property which depends on whether a number property is positive or negative.
import QtQuick 1.0 Rectangle { width: 360 height: 360 color: "blue"; property int number: -50; property bool positive: number > 0; Behavior on positive { ScriptAction { script: console.log("foo"); } } Component.onCompleted: { for (var i = 0; i < 100; i++) { number += 1; } } }
Expected result: Behavior on positive {} is called only once
Result: Behavior on positive{} is called 100 times.
The strange thing is that even though the Behavior change is called, if a slot onPositiveChanged is added it's not called. (so it does make a check Behavior doesn't)
Although I agree that may not be the purpose of Behavior (that kind of thing is somewhat the purpose of States), some other cases might be trickier, and if this bug is normal it should be at least specified in the documentation.