[Qt-interest] sendPostedEvents() does not dispatch all events

Nikos Chantziaras realnc at arcor.de
Sun May 2 14:34:17 CEST 2010


On 04/29/2010 07:13 PM, Nikos Chantziaras wrote:
> Since the documentation of QCoreApplication::processEvents() states that:
>
> "In event you are running a local loop which calls this function
> continuously, without an event loop, the DeferredDelete events
> will not be processed. [...] An alternative would be to call
> sendPostedEvents() from within that local loop."
>
> However, deleting a QObject with:
>
> someObj->deleteLater();
>
> and then doing:
>
> qApp->sendPostedEvents();
>
> does not result in 'someObj' being deleted. For that to happen, I have
> to explicitly call:
>
> qApp->sendPostedEvents(0, QEvent::DeferredDelete);

I just discovered that on Mac OS X (32-bit Cocoa), doing this results in 
the application eating 100% CPU.  This is the local loop:

   while (waiting_for_user_to_finish_input) {
     this->sendPostedEvents(0, QEvent::DeferredDelete);
     this->sendPostedEvents();
     this->processEvents(WaitForMoreEvents | AllEvents);
     this->sendPostedEvents();
   }

It seems on OS X, "processEvents(WaitForMoreEvents | AllEvents)" does 
not really wait and therefore CPU goes to 100% unless I remove the 
"sendPostedEvents(0, QEvent::DeferredDelete)" call.

Bug or expected behavior?



More information about the Qt-interest-old mailing list