On 1/27/2009 1:03 AM, P T Withington wrote:
On 2009-01-26, at 18:24EST, André Bargull wrote:
Oh wait, you just said nothing in the LFC depends on the current way
things work. I really believed in you,
But wait, I said:
"where a child node _needs_ to access it's parent when the parent is in
the process of being deleted"
so, there may be cases where it _does_ access the parent, but does it
_need_ to? I don't think it does. So it is just a matter of fixing
those cases to be careful.
How do you plan to find those cases? Whenever (immediate)parent is
referenced, you need to add extra if-condition to protect against
nullpointer dereferencing. For example what is going to happen for
constraints? The example [2] isn't a real-life example (it makes no
sense to do anything like that), but through replication [1] and other
means, you can end up destroying the parent-node and then it's really
difficult to find the source of possible runtime errors.
Both of your examples remind me of the chainsaw user who cuts the branch
he is standing on and then complains that the chainsaw did not prevent
him from a horrible accident. Are there really nodes that believe they
can delete their own parent (knowing that will result in their own
deletion)?
For example an one-way message dialog, if you close the dialog it should
be destroyed, too. So you add a button which calls destroy on the
parent-node on "onclick".
And I can also make the examples less obvious [1]:
- when replication is set to lazy, everything works
- but when replication is "normal", the app breaks and produces the same
error as in my earlier example
[1]
<canvas debug="true" >
<dataset name="ds" ><item /></dataset>
<view width="100%" height="100%" layout="axis:y" >
<view>
<datapath xpath="ds:/item" replication="normal" />
<view width="180" height="40" bgcolor="#eaeaea" clickable="true"
focusable="true" >
<text text="click and then press tab" />
<handler name="onclick" >
canvas.ds.appendChild(new lz.DataElement("item"));
</handler>
</view>
</view>
</view>
</canvas>
[2]
<canvas debug="true" >
<view>
<view width="100%" height="100%" bgcolor="#eaeaea" >
<handler name="onwidth" >
this.parent.destroy();
</handler>
</view>
</view>
</canvas>