[Interest] Relationship between a QEventLoop and QCoreApplication::exec().

Thiago Macieira thiago.macieira at intel.com
Wed Aug 3 22:41:51 CEST 2016


On quarta-feira, 3 de agosto de 2016 22:25:32 PDT Konstantin Shegunov wrote:
> On Wed, Aug 3, 2016 at 8:58 PM, Thiago Macieira <thiago.macieira at intel.com>
> 
> wrote:
> > On quarta-feira, 3 de agosto de 2016 11:22:36 PDT Jorge Fierro wrote:
> > > - If QEventLoop::exec() spins the main loop then any event at all can
> > > be generated. Is this why one must use it very carefully to avoid
> > > reentrancy issues?
> > 
> > Yes. Avoid nesting event loops like the plague.
> 
> With, I believe, the important exception being the deferred deletion
> events, which are processed only be the last (main) event loop.

Correct, the deletion events are only processed by an event loop of the same 
equally or less nested than when the event was posted. That exists because a 
lot of code depends on deleteLater() being much later than what was happening.

It's still a source of errors because the nesting counter can be incremented 
in different ways, depending on what triggered the event. So the 
recommendation remains: avoid nesting like the plague.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list