A little change on Gaphas

0 views
Skip to first unread message

oscarah

unread,
Jul 8, 2009, 3:53:13 PM7/8/09
to gaphor-dev
Hello again,

I'm progressing in my project ;) I've created an entity, Container,
which is, obviously, a virtual container. It only has the ability to
insert items on his own canvas as children, something like
'self._canvas.add(item, self)'.

In order to allow inserting items before adding the container to
canvas, I've delayed the insertion until parent canvas is ready. So, I
use the method "setup_canvas" to actually add children to canvas. But,
a problem arise! (of course ;) )

On method 'setup_canvas()' I can not add an item to canvas, using self
as parent. As example, next code will raise an exception:

def setup_canvas(self):
self._canvas.add(an_item, self)

The problem is that 'self' instance has not been fully added to
canvas, so 'update_matrix()' is not called yet. Then, 'self' has
'_matrix_i2c' to None.

I've tested a change for a while, without any problem. I've modified
the method 'canvas.add()', in order to call 'item._set_canvas()' at
the end. Thus, everything is finished, and I can add items.

What do you thing about it? May it introduce any problem?

Thanks for your time.
Oscar.

Arjan Molenaar

unread,
Jul 28, 2009, 2:37:17 AM7/28/09
to gapho...@googlegroups.com
Hi Oscar,

I've checked the code and I see no problem. It's a sound solution to
initialize as much as possible on the item before calling any item
specific logic.

I've committed the change.

Thanks,

Arjan

Reply all
Reply to author
Forward
0 new messages