[Qt-interest] seg faults in QApplication destructor?
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Thu Jan 8 20:21:52 CET 2009
IIRC, the QObject emits a "destroyed" signal, which the parent has a
slot connected to, it then removes it from the list.
So it only works when you have the event loop going, any access to the
pointer by the parent before it gets notification will cause a core
dump.
This is why, if you delete sender() either directly or by proxy, you
should call deleteLater()
Scott
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Alan Ezust
> Sent: Thursday, January 08, 2009 10:47 AM
> To: Sonic
> Cc: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] seg faults in QApplication destructor?
>
> Hrm... Come to think of it, you are right. When you delete a QObject,
> it should be removed from the child list of whatever parent it was in
> before... So forget that explanation.
>
> I'm trying to remember how I once had a segfault on exit, and what was
> the cause. It was related to out of order destruction of some sort,
> and changing the parent of a particular object made the problem go
> away... Because it was not supposed to be destroyed at that time.
>
> If I come up with a good example, I'll post it.
>
> On Wed, Jan 7, 2009 at 5:32 PM, Sonic <syamcr at gmail.com> wrote:
> > Alan Ezust wrote:
> >> If for example, you added a heap QObject to a pointer collection,
but
> >> it also has a parent which is indirectly or directly a child of one
of
> >> your QWidgets, or the QApplication. Then before exit, you iterate
> >> through the collection, deleting all the heap objects in it, but
they
> >> are still in the childlist of another QObject.
> >>
> > Will that happen? When I delete a QWdiget/QObject using the delete
> > operator, isn't it automatically removed from it's parent's list of
> > children?
> >
> >
> >> On Wed, Jan 7, 2009 at 3:33 PM, John Dailey
<john.w.dailey at gmail.com>
> wrote:
> >>
> >>> I am working on a QT4.3.4 project that I inherited and it is
behaving
> >>> in a manner that seems strange to me. It consistently seg faults
in
> >>> the QApplication destructor (according to GDB anyway). The back
trace
> >>> generated when it does seg fault is not consistant, but it seems
to go
> >>> through QHash and free on it's ultimate path to oblivion. I am a
> >>> novice when it comes to QT and to gui programming in general so I
fear
> >>> I may be missing something obvious.
> >>>
> > Are you using command line arguments (in main() and passed on to
> > QApplication?
> >
> > Syam
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> >
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list