[Kde-games-devel] KGameCanvas
Mauricio Piacentini
mauricio at tabuleiro.com
Mon Oct 2 04:50:31 CEST 2006
> The "while" thing should work anyway, because when an item is destroyed
> it is automatically removed from the abstract canvas (so the canvas does
> not hold a dangling pointer). On the other side, when an abstract canvas
> is destroyed, all its items are made "orphan" items (same as if
> putInCanvas(NULL) was called for eachitem), so that they do not point
> to a destroyed canvas, but they may be reused in another canvas (i don't
> know if this is useful, but who know).
It is probably useful on some scenario. Or at least there is no harm in
having this option available.
> When i designed the canvas i did not put any memory management in it
> to make the design more clear, but if you think that an "autoDeleteItems"
> flag could be useful, it can be added with very little work.
> Or, you can just do:
> while ( ! items()->isEmpty() )
> delete items()->first();
Or maybe qDeleteAll(items()), followed by m_items().clear. I had already
implemented a clearAll in libkdegames, will just update it.
> note first instead of takeFirst. You should never modify the items
> list out of the
> canvas (to make design clear and keep things consistent), this is why
> you get
> the constness error, but if you just simply delete an item it will be
> automatically
> removed from its list :)
K, thanks for the clarifications.
Regards,
Mauricio
More information about the kde-games-devel
mailing list