On Sun, 27 Mar 2011 22:29:38 -0400, Luke Campagnola <[email protected]> wrote: > Greetings All-Knowing PyQters, > I have a strange bug that's causing segmentation faults in my program. I > have identified some of the key contributors to the bug and a workaround, > but I would love for someone to explain what causes the crash so I can > avoid > similar problems in the future. > > Here are the things required to cause the crash: > 1) Repeatedly creating and deleting a GraphicsView and GraphicsItem > 2) The each GraphicsItem has a reference to the GraphicsView it is shown in > 3) Having a second thread running and actively working > > Usually a segmentation fault will occur after roughly 10-1000 create/delete > cycles. Taking away any of these components prevents the crash. The second > thread does not have to be doing anything specific and does not even have > to > be a QThread; it just has to be doing _something_. If the Item has a > weakref > to its View, there is no crash (and this is a perfectly acceptable > workaround). > > I have attached a GDB backtrace and a short script demonstrating the bug. > When I run the script on my system (Ubuntu 10.04, PyQt 4.7.2), about half > of > the time it causes a segfault, and the rest of the time it just freezes. > I've also tested the script on WinXp with PyQt 4.8.3 and 4.5.4, with > similar > results. PySide does not have the bug, so I suspect it is not a Qt issue. > > Any advice would be greatly appreciated! > > Luke
PyQt keeps track of certain types of object that are known to cause problems if they are garbage collected before the QApplication - QGraphicsScene is one of these. It seems that QObjectCleanupHandler has problems in a threaded application. Fixed (or at least worked around) in tonight's PyQt snapshot. Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
