[Development] Is Qt Quick Item properties order significant?
Mitch Curtis
mitch.curtis at qt.io
Fri Mar 9 10:17:31 CET 2018
> -----Original Message-----
> From: Development [mailto:development-bounces+mitch.curtis=qt.io at qt-
> project.org] On Behalf Of Tomasz Olszak
> Sent: Friday, 9 March 2018 10:13 AM
> Cc: development at qt-project.org
> Subject: Re: [Development] Is Qt Quick Item properties order significant?
>
> Yes, I would like to thank Simon and Mitch for taking care of this.
I did nothing, all props go to Simon. :)
> The prospect of spending few days on reviewing code and rearranging
> properties was not making me happy :)
>
> 2018-03-09 1:44 GMT+01:00 Jason H <jhihn at gmx.com>:
> > Neat! I've never seen a patch land that fast! I'm going to be happy with this
> one!
> >
> >
> >> Sent: Thursday, March 08, 2018 at 7:11 AM
> >> From: "Tomasz Olszak" <olszak.tomasz at gmail.com>
> >> To: No recipient address
> >> Cc: development at qt-project.org
> >> Subject: Re: [Development] Is Qt Quick Item properties order significant?
> >>
> >> With help from IRC I submitted regression Bug:
> >> https://bugreports.qt.io/browse/QTBUG-66945
> >>
> >>
> >> 2018-03-08 8:25 GMT+01:00 Tomasz Olszak <olszak.tomasz at gmail.com>:
> >> > The same behavior is when tmp1 is initialized with C++ function.
> >> > Function is called twice too.
> >> >
> >> > 2018-03-08 8:15 GMT+01:00 Tomasz Olszak
> <olszak.tomasz at gmail.com>:
> >> >> Hi thanks for feedback,
> >> >>
> >> >> I agree that putting everything in Component.onCompleted would be
> >> >> worse workaround than changing order but more explicit. On the
> >> >> other hand it is a lot less declarative.
> >> >>
> >> >> In my application I build different kinds of settings using list
> >> >> of objects or strings. I encountered this issue while building
> >> >> list of Time Zones. The Item that contained this list was
> >> >> instantiated in more than a second. Then I realized that the
> >> >> function that creates and filters list is called twice. There are
> >> >> numerous places in my application that uses function to initialize object
> properties.
> >> >>
> >> >> Moreover if I change tmp0 to: "property int tmp0: tmp1 + 1"
> >> >> getTmp1Value is still called twice which seems like a bug.
> >> >> AFAIK Qt knows dependencies between bindings because it triggers
> >> >> reevaluation in dependent property has changed. Seems like this
> >> >> dependency is ignored during initialization phase. Depending on
> >> >> complexity and duration of execution of bindings expression
> >> >> instantiation of component can be almost twice longer without any
> explicit cause.
> >> >>
> >> >> Am I right or missing something?
> >> >>
> >> >> 2018-03-08 4:53 GMT+01:00 Jason H <jhihn at gmx.com>:
> >> >>>
> >> >>> 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" <olszak.tomasz at gmail.com>
> >> >>> To: development at qt-project.org
> >> >>> Subject: [Development] Is Qt Quick Item properties order significant?
> >> >>> 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
> >> >>>
> >> >>>
> >> >>> _______________________________________________
> Development
> >> >>> mailing list Development at qt-project.org
> >> >>> http://lists.qt-project.org/mailman/listinfo/development
> >> _______________________________________________
> >> Development mailing list
> >> Development at qt-project.org
> >> http://lists.qt-project.org/mailman/listinfo/development
> >>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
More information about the Development
mailing list