[Development] Question about deferred delete handling in sendPostedEvents

Shaw Andy Andy.Shaw at digia.com
Mon Feb 17 15:35:08 CET 2014


Hi,

I was looking at a problem regarding deferred deletes causing a crash inside nested loops and it was pointed out that in QCoreApplication::setPostedEvents() there is some code there that determines whether it is safe to delete the object or not. From my understanding it will only delete an object if the loop level that it was called from is greater than the current one. However it seems that if the loop level is 0 (i.e. main event loop I guess) and the current one is higher than 0 it deletes anyway, is this the correct intention? Does anyone know why this is safe if so?

For reference the code is this bit specifically:

            const bool allowDeferredDelete =
                (loopLevel > data->loopLevel
                 || (!loopLevel && data->loopLevel > 0)
                 || (event_type == QEvent::DeferredDelete
                     && loopLevel == data->loopLevel));

Where loopLevel is 0 but data->loopLevel is greater than 0.

Regards,
Andy



More information about the Development mailing list