[PyQt] Segmentation Fault

Fred pyqt at dezwietjes.nl
Thu Nov 29 21:15:49 GMT 2007

I found the problem. Thank you for the reply.

On Thursday 29 November 2007 19:56:57 Giovanni Bajo wrote:
> On 11/29/2007 12:03 PM, Fred wrote:
> > I've got a difficult to track problem. I'm creating a game to learn PyQt
> > and I'm sure I am missing something really, really obvious, but still:
> > can't find it.
> >
> > I made a grid of tiles. Every tile is a graphicsItem on a scene. I've
> > made a dictionary of tiles where the key is the coordinates on the grid
> > (x,y) and the content is (a reference to) the qgraphicsItem.
> >
> > On a certain point in the game, during a mousepressevent, I need to
> > remove a certain amount of tiles. In a for loop I remove the
> > qgraphicsitem from the scene and from the dictionary and I delete the
> > item itself (del item).
> >
> > Then, when it enters the eventloop again, it segfaults. I'm sure it has
> > something to do with the way I delete the item's. When I delete it from
> > the scene, but keep it in the dictionary, it works (well, it doesn't
> > segfault). If I remove it from the dictionary, but not from the scene, it
> > works too. My guess is that it works in those to cases, because the item
> > itself is then not deleted. But I want it deleted. Somehow, when I get
> > back into the eventloop, the removed items are still expected to be
> > there.
> >
> > Any hints?
> We're short on magicians lately :)
> Please post a complete, runnable source code example that reproduces the
> bug. But let me guess that you're doing something weird with ownership
> of the items...

More information about the PyQt mailing list