[Development] Is Qt Quick Item properties order significant?

Tomasz Olszak olszak.tomasz at gmail.com
Wed Mar 7 10:25:46 CET 2018


Hello,

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
getTmp0Value");
        return 1;
    }
    function getTmp0Value(arg) {
        console.log("getTmp0Value should be called only once and aftere
getTmp1Value");
        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?

Tomek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20180307/b5de5d6e/attachment.html>


More information about the Development mailing list