DO NOT delete QObjects, mmmkay?

Andreas Pakulat apaku at
Thu Nov 8 21:50:40 GMT 2007

On 08.11.07 14:17:15, Aaron J. Seigo wrote:
> On Thursday 08 November 2007, Andreas Hartmetz wrote:
> > All in all I have fixed three or four crashes in various KDE modules where
> > QObjects were deleted while a signal/slot call involving that QObject was
> > going on.
> p.s. the usual solution when you need to have a QObject deleted is to call 
> deleteLater() on the object instead of delete'ing it with the C++ keyword.

Yeap, though I just had a case where I needed 2 event-loop runs to
safely delete some qobject-derived stuff (in particular plugins).

> p.p.s. the QObject::destroyed(QObject*) signal can be very handy at times, 
> too.

That helped in my case, deleting the first QObject with deleteLater and
the next QObjects then when the signal is emitted...


Do not overtax your powers.

More information about the kde-core-devel mailing list