[PyQt] Help tracking down intermittent segfault using QGraphicsItem

Kovid Goyal kovid at kovidgoyal.net
Mon Jan 7 04:04:44 GMT 2013


Since it seems to be a fix, which indicates the issue is object
ownership/lifetime, you can try an approach that avoids the warning.

For example, dont give item1 a parent, instead add it to the scene, and
when deleting item0 add code to manually delete item1. 

You can also try using the API in
http://www.riverbankcomputing.com/static/Docs/sip4/python_api.html
to manually manage the object ownership, deletion semantics.

Kovid.

On Mon, Jan 07, 2013 at 02:05:27AM +0430, Lee Harr wrote:
> 
> >> The strangest part is that if I manually add item1 to the scene
> >> (should not be needed since the child is automatically added when
> >> the parent is added) I do not get the segfault.
> 
> 
> > From the description of the OPs problem I'd guess that it is
> > an object lifetime issue. Registering the child graphics item
> > with the scene probably causes the scene to become the owner of that
> > object in Qt which prevents the crash.
> 
> 
> If I read you correctly, you are saying that this is probably
> "fixing" the problem.
> 
> So, if I can get over not wanting the ugly warning, it's probably
> safe to ship it like this.
> 
> 
> I have gone through and everywhere I was throwing away
> python references to old Qt objects I instead just hold on to
> the old one, and that has reduced the chance of a segfault
> significantly, but it still happens occasionally. So I'm still
> searching for objects that are getting released too early.
> 
> Manually adding that one object to the scene seems to
> fix it completely...
> 
> 
> Thanks for your help!
> 
>  		 	   		  
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,50e9ee2e47621161344975!
> 
> 

-- 
_____________________________________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_____________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130107/ec0de969/attachment.pgp>


More information about the PyQt mailing list