A few places. Not PyQt's fault. It's not possible to reconcile object lifetime issues completely robustly between two different object systems over which you have very limited control.
Here's the last example that bit me (this segfaults on linux, not other OSes). python -c "from PyQt4.Qt import *; app = QApplication([]); f = QRawFont.fromFont(QFont('Arial'));" The segfault can be prevented by causing the python reference to the QRawFont to be explicitly deleted before app is deleted, like this: python -c "from PyQt4.Qt import *; app = QApplication([]); f = QRawFont.fromFont(QFont('Arial')); del f" In this case, it happens because the FreeType library (used by QRawFont) is being destroyed before the python QRawFont object is deleted. 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. Kovid. On Sat, Jan 05, 2013 at 07:12:34PM +0100, mathias.b...@gmx.de wrote: > On 05.01.2013, 16:50:29 Andreas Pakulat wrote: > [...] > > Often a segfault is caused by using a pointer (in C++) which points to > > a memory location thats not valid anymore, for example because the > > object has been deleted already. In the context of PyQt this can > > happen when you stop keeping references to objects that or instances > > of C++-provided classes in python. In such a case the C++ parts of the > > object will be deleted and thus any other C++ code that has a > > reference to the object will crash when it tries to access the object. > > I think thats the most common problem one encounters with PyQt4. > > While this is certainly true in general, I'd say that sip goes to > great length in order to avoid that kind of crash by carefully > observing who owns what. It is aware of the parent-child memory > management of Qt. A python program should never be able to cause a > crash. Is there any place in PyQt where the Python code has to keep > references to keep the program going? > > Best Regards, > Mathias Born > > > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > !DSPAM:3,50e86d3047621890519808! > > -- _____________________________________ Dr. Kovid Goyal http://www.kovidgoyal.net http://calibre-ebook.com _____________________________________
signature.asc
Description: Digital signature
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt