[PyKDE] Segmentation fault with dynamic creating of widget content
Henry Kleynhans
henry at obsidian.co.za
Tue Jun 17 15:17:00 BST 2003
Ummm...I must say that I also get a similar type of segfault.
My situation is that I do:
myparent.removeChild(myChild)
del myChild
Under cetain conditions when I swap applications the app segfaults. I can't
simulate the situation since it does not work the same each time. But I
suspect that it has something to do with the way in which event handling
works, since in my application an event causes certain widgets to get deleted
and others to be placed in their place; i.e. a widget can send a signal
causing it's own destruction. It works in a simple example, but it does not
seem to work as well when the application gets more complex.
Kind regards,
Henry
On Tuesday 17 June 2003 14:39, Phil Thompson wrote:
> On Tuesday 17 June 2003 10:40 am, Wido Depping wrote:
> > On Tuesday 17 June 2003 10:26, Phil Thompson wrote:
> > > On Monday 16 June 2003 11:34 pm, Wido Depping wrote:
> > > > I have a widget whose children are created dynamicly. if i get new
> > > > data i have to refresh the widget, delete all it's children and
> > > > create the child-widgets again. Most of the time this method works,
> > > > but sometimes i get a segmentation fault.
> > > > This is the method for the deletion of the children:
> > > > for x in self.attributeWidget.children():
> > > > name = str(x.name())
> > > > # this ensures, that the layout is not deleted
> > > > # every label, lineedit and button has a name which starts with
> > > > 'LDAP' if name[:4] == "LDAP":
> > > > x.destroy()
> > > > self.attributeWidget.removeChild(x)
> > > >
> > > > So, is my code wrong or is it PyQt's fault? Attached is a backtracke
> > > > i got from gdb:
> > >
> > > What happens if you call removeChild() before you call destroy()?
> >
> > Then I get a segmentation fault, too. This time it happens, if I refresh
> > the widget and then press 'Alt'. It also happens if I minimize and
> > restore the window. Also with the same backtrace.
> > That's why I executed the destroy() before removeChild().
>
> You should definately do the removeChild() first. I would also "del x"
> rather than "x.destroy()". Other than that, have you got a small, but
> complete, example that demonstrates the problem.
>
> Phil
>
> _______________________________________________
> 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