I'm writing here because I don't know if it is a bug or intended behavior
and I should look more carefully in docs (haven't found anything mentioning
it yet).

Please consider 2 examples (can be pasted anywhere - you will see logs from
object initialization):
Item {
    property int tmp0: getTmp0Value(tmp1)
    property int tmp1: getTmp1Value()
    function getTmp1Value() {
        console.log("getTmp1Value should be called only once and before
        return 1;
    function getTmp0Value(arg) {
        console.log("getTmp0Value should be called only once and aftere
        return arg + 1;

And with small modification (order of properties has changed):
Item {
   property int tmp1: getTmp1Value()
   property int tmp0: getTmp0Value(tmp1)

First one calls getTmp1Value twice, second one - as expected only once.
Seems like when tmp0 is initialized it does not initialize tmp1 first as
dependency but takes expression binding from tmp1 executes it and assign
result to tmp0, then executes the same expression for tmp1 to initialize it.

Is it a bug or do I miss something?

Development mailing list

Reply via email to