[Interest] Double destruction of Qt objects in Qt example code?

Scott Aron Bloom Scott.Bloom at onshorecs.com
Sat Aug 18 22:55:09 CEST 2012


IIRC the list is stored in the event list, and it will go over each one..  Its not terribly expensive but isn't free either.

The only time I every call deleteLater is when I have to delete something, AND the function I am in, is in the middle of the event loop, AND the object will be used again, ie QEvent flows

Scott

-----Original Message-----
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Nikos Chantziaras
Sent: Saturday, August 18, 2012 1:44 PM
To: interest at qt-project.org
Subject: Re: [Interest] Double destruction of Qt objects in Qt example code?

On 18/08/12 23:21, André Pönitz wrote:
> On Sat, Aug 18, 2012 at 09:29:53PM +0300, Nikos Chantziaras wrote:
>>  [...]
>> On a similar note, don't delete QObject instances manually.  Call 
>> their
>> deleteLater() member function instead.
>
> There are only rare cases where deleteLater is needed.
> Otherwise, using it is unneeded overhead.

How much of an overhead?  I think it's preferable to trade a tiny bit of overhead for event propagation safety.  The event loop might not be finished with the object at the time of deletion.

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list