I can see your point. But tmp1 is not changing during the first property init, so it won't be evaluated. The way to work around this order-specifc init is to do it explicitly in a Component.onCompleted
Sent: Wednesday, March 07, 2018 at 4:25 AM
From: "Tomasz Olszak" <[email protected]>
To: [email protected]
Subject: [Development] Is Qt Quick Item properties order significant?
From: "Tomasz Olszak" <[email protected]>
To: [email protected]
Subject: [Development] Is Qt Quick Item properties order significant?
Hello,
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;
}
}
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/developmentI'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
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
