[PyKDE] PyQT Segfault on widget removal.

Phil Thompson phil at riverbankcomputing.co.uk
Wed Jun 18 13:28:01 BST 2003


On Wednesday 18 June 2003 12:17 pm, Wido Depping wrote:
> On Wednesday 18 June 2003 12:59, Henry Kleynhans wrote:
> > On Wednesday 18 June 2003 09:40, Vio wrote:
> > > > >Given the recent segfault discussion, I have attached an example
> > > > > piece of code which segfaults.  I am not sure if this is a bug, or
> > > > > just my own stupidity though.  According to the PyQT book, the way
> > > > > to remove a widget from it's parent is to do the following:
> > > > >
> > > > >	myParent.removeChild(myChild)
> > > > >	del myChild
> > > > >
> > > > >The PyQT/Sip bindings seems to break if these commands gets
> > > > > triggered by a signal from within a child widget of the widget that
> > > > > is to be removed.
> > > > >
> > > > >I get a segfault when I do the following:
> > > > >
> > > > >	1.  Run the program (testdel.py)
> > > > >	2.  Click on the DelButton button.
> > > > >	3.  Switch to another application using Alt-Tab
> > > > >	4.  Switch back to my testdel app.
> > > > >
> > > > >This happens under RH9.0. (Python-2.2.2-26, PyQt-3.5-5, qt-3.1.1-6) 
> > > > > I use the KDE desktop environment.
> > > > >
> > > > >Does anyone know if this is a bug or how to fix/workaround this?
> > > >
> > > > I remember similar problems usind "delete()" or "destroy()" some time
> > > > ago  - sorry, I forgot the exact method name.
> > > > My simple workaround was to use "deleteLater()". Especially since
> > > > "Later" appears to be calcutated in milliseconds: pretty fast.
> >
> > Would you use deleteLater() instead of removeChild() ?
> > The problem is that it works if the button is not inside another widget
> > which gets removed.  If you have the button on the QMainWindow instead of
> > the TestWidget, it works fine, but as soon as you put in into another
> > widget it does not work.
>
> Thanks for the tip. Now my application runs without any problems.
> Should this be mentioned in the FAQ until it is fixed in the next release?

I'll add it to the FAQ, but I don't think it's a PyQt bug - unless anybody 
wants to do a C++ version of the test case and prove me wrong.

BTW, the pyuic problem is fixed in the current snapshot.

Phil




More information about the PyQt mailing list