[PyQt] Segmentation Fault
Giovanni Bajo
rasky at develer.com
Thu Nov 29 18:56:57 GMT 2007
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...
--
Giovanni Bajo
More information about the PyQt
mailing list