DO NOT delete QObjects, mmmkay?
Diego Iastrubni
elcuco at kde.org
Thu Nov 8 21:32:34 GMT 2007
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.
>
> p.p.s. the QObject::destroyed(QObject*) signal can be very handy at times,
> too.
>
>
Yes, but be warned, that signal is emitted *after* the QObject has been
deleted. So, if you want to retrieve something out a "soon to be
deleted" object, it will not help you as the parameter sent is a
dangling pointer.
More information about the kde-core-devel
mailing list