[Development] Allowing event delivery prior to and after QCoreApplication
Olivier Goffart
olivier at woboq.com
Wed Jan 14 02:17:31 CET 2015
On Tuesday 13 January 2015 16:28:02 Thiago Macieira wrote:
[...]
> sendEvent is used by QCoreApplicationPrivate::sendPostedEvents, which in
> turn is the core of event dispatching in Qt (all event dispatchers'
> processEvents call it).
>
> As you can see from the code above, event delivery is stopped when
> QCoreApplication::self is null. This means any event delivery attempted
> prior to the QCoreApplication creation or after its destruction silently
> fails. This includes the deleteLater() event, as well as timer events and
> QSocketNotifier's event. In other words, almost everything stops.
>
> Do we need still need that behaviour?
Maybe not. Maybe we could decouple the event processing from
QCoreApplication. Maybe in the long term we might even not require a
QCoreApplication at all?
(Just run QThread::current()->exec() or QEventLoop().exec() instead of
app.exec())
But the application may override QCoreApplication::notify.
The programmer might also set a global eventFiler.
This is the main behaviour that you would change, that some event might escape
notify or the filters (if it the event is send to early).
Is it OK that early (or late) event bypass the filters?
> Finally, note what happens if there's a thread trying to deliver events
> *while* QCoreApplication is being shut down: notifyInternal() is probably
> dereferencing a dangling pointer.
Good point.
But one might argue that thread should be finished before the QCoreApplication
is destroyed.
--
Olivier
Woboq - Qt services and support - http://woboq.com - http://code.woboq.org
More information about the Development
mailing list