Ugly bug in bindings

Pavel Vasev pavel.vasev at gmail.com
Tue Mar 3 11:41:52 UTC 2015


Hi Anton!

Many thanks to you for the fix! I tested on my cases and all is OK now.

------------------------------------

Because we are already in bindings fixing, I would like to ask you to look
at another strange situation

***********************
import QtQuick 1.1

Rectangle {
  width: 100
  height: 100
  color: "green"

  property var pos: make()
  property var nodes: [1,2,width]

  function make() {
    console.log("called make, nodes=",nodes);
    return nodes;
  }

}
***********************

If you open this exampe, you will see that `called make` message is logged
twice to the console.

called make, nodes= undefined
called make, nodes= [1, 2, 100]

As I understand, this is because bindings are evaluated in some order
during init.
And when binding eval uses another binded property, of which binding is not
initialized, the first one gets "undefined value".

As a variant, I think binding eval shoul be recursive (with loop detection
build in it).

If you want, I may try to fix it by myself. In that case, please confirm
that `recursive idea` is right.



С уважением,
Павел Васёв

2015-03-03 13:37 GMT+05:00 Anton Kreuzkamp <akreuzkamp at web.de>:

> uh, nice one.
>
> The problem was, that the binding was overwritten with a constant value.
> But
> bindings are always evaluated last. Thus the binding won.
>
> Fixed by properly removing the binding, when being overwritten.
>
> Please test again with your code.
>
> Cheers, Anton
>
> On Monday 02 March 2015 21:51:25 you wrote:
> > Dear Anton!
> >
> > Please look at following example:
> >
> > ----------------------------------------------- main.qml
> > import QtQuick 1.1
> >
> > Rectangle {
> >   anchors.fill: parent
> >   color: "green"
> >
> >   Subitem {
> >     id: qSome
> >     coords: [5,2,3]
> >   }
> > }
> >
> > ----------------------------------------------- Subitem.qml
> > Item {
> >     id: origin
> >     property var coords: parent.coords
> >     // maybe parent will have coords property?
> >     // if not, we consider that implementor of Subitem object will
> specify
> > coords directly
> >     // see above, we set coords property to [5,2,3]
> >
> >     property var positions: make()
> >
> >     function make() {
> >         console.log("called make, coords=",origin.coords );
> >         return origin.coords;
> >     }
> >
> > }
> > -----------------------------------------------
> >
> > The result of that code should be seen in console.
> > We see:
> >
> > called make, coords= undefined
> >
> > But the correct result should be:
> >
> > called make, coords= [5,2,3]
> >
> > Maybe, I misunderstand something?
> >
> > Best Regards,
> > Pavel Vasev
>
> --
> Gruß auch an die NSA.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/qmlweb/attachments/20150303/affc3d73/attachment.html>


More information about the QmlWeb mailing list