On Wednesday 17 January 2007 3:52 pm, Giovanni Bajo wrote: > On 1/17/2007 2:07 PM, Phil Thompson wrote: > >> this script causes a segfault for me with latest SIP snapshot and PyQt > >> 3.17: > >> > >> ================================================ > >> from qt import * > >> app = QApplication([]) > >> k = QWidget(None) > >> qApp.postEvent(k, QCustomEvent(QEvent.User)) > >> del app > >> ================================================ > > > > Is this a recent problem with current snapshots? > > This specific testcase crashes also with older versions of SIP and PyQt > (4.4 and 3.16). > > I'm getting a serie of crashes, all related to QApplication destruction > and event delivery, which never triggered before but now trigger with > recent SIP snapshots. This is the first testcase reduction I made (they > are pretty difficult to reduce!). I have probably at least another to > report that I'm still reducing. > > > Is there a real use case (you'd never actually code the above)? Otherwise > > just remove the "del". > > Yes, the real use case is an automatic testsuite. For each test, I need > to create and destroy a new QApplication to start afresh. It kind of > works in C++, but I have historically always had troubles with PyQt. A > generic workaround for me right now is to put a qApp.processEvents() > before app destruction, but I would prefer if the bugs were fixed (and I > thought you preferred it too...).
I'm not convinced it's a bug given that you have no control on the order in which things get torn down from Python. Even if it is a bug, I'm not sure it is possible to fix it (for the same reason). If you can't avoid the "del app" then preceding it with a "del k" also avoids the crash - which is just another way of imposing an order on the normal chaos that happens when the interpreter exits. That would suggest that if, in C++, you destroyed the QApplication before the QWidget you would also get the crash. Phil _______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
