[Development] QPA triggers nested event processing

Simon Hausmann simon.hausmann at nokia.com
Fri Aug 3 13:16:37 CEST 2012


On Friday, August 03, 2012 12:52:08 PM ext David Faure wrote:
> This was quite unexpected: in Qt5, creating a QApplication instance triggers
> event processing already, much before calling QApplication::exec().
> 
> This comes from QWindowSystemInterface::sendWindowSystemEvents calling
> sendPostedEvent(), see bt below. Shouldn't it be more specific about which
> posted events, for which targets, should be flushed at that point?

Yeah...
 
> I'm pretty sure that nobody expects other events (timers, sockets, dbus,
> etc.) to be handled yet. Even processing GUI-related events doesn't sound
> like a good idea to me, so early in the game.
> 
> #7  0x00007ffff3ba16fd in q_dbus_connection_dispatch (connection=0x61c6b0)
> at qdbus_symbols_p.h:115 #8  0x00007ffff3ba6e6e in
> QDBusConnectionPrivate::doDispatch (this=0x612600) at
> qdbusintegrator.cpp:1125 #9  0x00007ffff3bee5fe in
> QDBusConnectionPrivate::qt_static_metacall (_o=0x612600,
> _c=QMetaObject::InvokeMetaMethod, _id=3, _a=0x61c220) at
> .moc/debug-shared/moc_qdbusco nnection_p.cpp:130
> #10 0x00007ffff70ab991 in QMetaCallEvent::placeMetaCall (this=0x61f770,
> object=0x612600) at kernel/qobject.cpp:467 #11 0x00007ffff70ac8f8 in
> QObject::event (this=0x612600, e=0x61f770) at kernel/qobject.cpp:1048 #12
> 0x00007ffff70728e8 in QCoreApplicationPrivate::notify_helper
> (this=0x626750, receiver=0x612600, event=0x61f770) at
> kernel/qcoreapplication.cpp:837 #13 0x00007ffff70725dc in
> QCoreApplication::notify (this=0x7fffffffd330, receiver=0x612600,
> event=0x61f770) at kernel/qcoreapplication.cpp:783 #14 0x00007ffff3f0a80e
> in QGuiApplication::notify (this=0x7fffffffd330, object=0x612600,
> event=0x61f770) at kernel/qguiapplication.cpp:1052 #15 0x00007ffff70724e8
> in QCoreApplication::notifyInternal (this=0x7fffffffd330,
> receiver=0x612600, event=0x61f770) at kernel/qcoreapplication.cpp:721 #16
> 0x00007ffff707622d in QCoreApplication::sendEvent (receiver=0x612600,
> event=0x61f770) at kernel/qcoreapplication.h:207 #17 0x00007ffff70735ac in
> QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0,
> data=0x607df0) at kernel/qcoreapplication.cpp:1321 #18 0x00007ffff707316d
> in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at
> kernel/qcoreapplication.cpp:1181 #19 0x00007ffff3efd466 in
> QWindowSystemInterface::sendWindowSystemEvents (flags=...) at
> kernel/qwindowsysteminterface.cpp:509 #20 0x00007ffff3f0a449 in
> QGuiApplicationPrivate::init (this=0x626750) at
> kernel/qguiapplication.cpp:880 #21 0x00007ffff3f0860d in
> QGuiApplication::QGuiApplication (this=0x7fffffffd330, p=...) at
> kernel/qguiapplication.cpp:348 #22 0x00007ffff46b4d15 in
> QApplication::QApplication (this=0x7fffffffd330, argc=@0x7ffff6bf5568,
> argv=0x624270, GUIenabled=true, _internal=327680) at kernel/qapplication
> .cpp:577
> [...]
> #26 0x0000000000402cf8 in main (argc=1, argv=0x7fffffffd598) at
> /d/kde/src/kf5-qt5/kdelibs-frameworks/staging/kde4support/autotests/kunique
> apptest.cpp:93
> 
> What's the reason for the sendWindowSystemEvents in
> QGuiApplicationPrivate::init ? It comes from
> ef2efafcc6b28791df6258fa1c5d565090a9577a (hi Simon), but the above looks
> like a rather unexpected large side effect for a small issue...

The specific case of ef2efafcc6b28791df6258fa1c5d565090a9577a comes from the 
MeeGo plugin that uses dbus properties to determine the screen orientation and 
sends a screen orientation change event on startup. Processing this window 
system even here helps to ensure that the initial screen orientation is 
correct.

It sounds like sendPostedEvents() without any parameters is indeed a little 
bit too aggressive. Laszlo, Paul, any thoughts?

Unless perhaps QApplicationPrivate::init should call 
QWindowSystemInterface::flushWindowSystemEvents instead?


Simon



More information about the Development mailing list