On Wednesday 06 July 2005 9:40 am, Yann COINTEPAS wrote: > Setting an event filter to the QApplication singleton and using threads > lead to a Python crash due to a double deletion of a widget (at Python > level). This happens with PyQt 3.14.1 and sip 4.2.1. I don't know if it is > the same for other versions. > > For example, the following code: > > import sys, threading > from qt import * > > class EventFilter( QObject ): > def eventFilter( self, o, e ): > return False > > class TestWidget( QWidget ): > def __init__( self ): > print '!init TestWidget!', threading.currentThread() > QWidget.__init__( self ) > > def __del__( self ): > print '!del TestWidget!', threading.currentThread() > > def createWidget(): > qApp.lock() > try: > w = TestWidget() > w.show() > del w > finally: > qApp.unlock() > > > app = QApplication( sys.argv ) > > theEventFilter = EventFilter() > qApp.installEventFilter( theEventFilter ) > > main = QLabel( 'main', None ) > main.show() > app.setMainWidget( main ) > > t = threading.Thread( target=createWidget ) > t.start() > > app.exec_loop() > > > Produces the following output: > > !init TestWidget! <Thread(Thread-1, started)> > !del TestWidget! <Thread(Thread-1, started)> > !del TestWidget! <Thread(Thread-1, started)> > Segmentation fault > > I even try to create widgets only from the main thread (instead of using > qApp.lock/qApp.unlock) by using a QTimer and a queue of functions and > arguments. But the result is the same.
With current snapshots I don't get the double delete and get a SIGKILL rather than a seg fault. The above code definately breaks Qt's rules - you must must create QWidgets in the main GUI thread. I need another example that demonstrate's the problem but conforms to Qt's rules. Phil _______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
