[PyKDE] PyQT Segfault on widget removal.

Henry Kleynhans henry at obsidian.co.za
Wed Jun 18 13:30:01 BST 2003


Hi Wido,

I'm not sure that this is a proper workaround for the problem yet...or how to 
define the problem properly :-(  I am experiencing the same type of problems 
in my current application, but I would have hoped that there would be a 
proper way of doing it.

I would think that the problem occurs due to the fact that the signals in Qt 
are blocking, i.e. when emiting a signal, the handing method will block 
untill the signal has been handled by all objects.  By that time the object 
which has emited the signal has been deleted...but that's my 5c worth.  

The problem might also have to do with the synchronization of deleted objects 
in the SIP library...I'm just not sure.

Kind regards,

Henry

On Wednesday 18 June 2003 13:17, 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?
>
> Wido
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

-- 
Henry Kleynhans <henry at obsidian.co.za>
Obsidian Systems




More information about the PyQt mailing list