[PyKDE] QCanvasSprite and QPixmapArray scope issues
phil at riverbankcomputing.co.uk
Fri Apr 28 15:01:58 BST 2006
On Friday 28 April 2006 2:27 pm, Alexander Borghgraef wrote:
> On 4/28/06, Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> > QCanvasSprite does not take responsibility for calling the QPixmapArray
> > dtor,
> > ie. it doesn't take ownership of the QPixmapArray instance. Therefore,
> > when
> > the latter goes out of scope it is garbage collected (unless there is
> > another
> > reference to it). Your solution is the conventional way of handling it.
> > Python isn't C++.
> I gathered that :-) Ok, but how about QCanvas? Apparently, the canvas
> *does* take ownership of
> any item put on it, even though its situation is similar to that of
> QCanvasSprite. Or does it just seem
> that way, and am I taking horrible risks with the example in my previous
> post which for some odd
> reason haven't blown up in my face yet?
Yes, QCanvas takes ownership of QCanvasItems so you don't need to keep a
reference yourself to prevent them from being garbage collected.
More information about the PyQt