[Interest] QWindowSystemInterface::flushWindowSystemEvents() causes signals to be handled in the wrong order?

Michel Rosien michel.rosien at gmail.com
Wed Aug 7 10:19:34 CEST 2013

Hello All,

I recently upgraded to Qt5.1 (from Qt4.8) and started noticing strange
behavior with signal handling.
It looks like signals are being handled while another signal is still being

In this call stack:

  Qt5Guid.dll!QWindowSystemInterface::flushWindowSystemEvents() Line 554 C++
  qwindowsd.dll!QWindowsWindow::~QWindowsWindow() Line 847 C++
  qwindowsd.dll!QWindowsWindow::`scalar deleting destructor'(unsigned
int) C++
  Qt5Guid.dll!QWindow::destroy() Line 1489 C++
  Qt5Widgetsd.dll!QWidgetPrivate::deleteTLSysExtra() Line 917 C++
  Qt5Widgetsd.dll!QWidget::destroy(bool destroyWindow=true, bool
destroySubWindows=true) Line 204 C++
  Qt5Widgetsd.dll!QWidget::~QWidget() Line 1484 C++
you see that the flushWindowsSystemEvents is called as part of the ~QWidget
It seems that this call causes pending signals to be handled immediately.

In my application a QWidget can be created/destroyed using a toggle button.
If the button is pressed rapidly, so many 'on' - 'off' - 'on' - 'off'
signals are being send, it can occur that an 'on' signal is handled while
an 'off' handler is still in progress (because the 'off' handler deletes
the widget)

Am I forced to use deleteLater instead of delete for a QWidget in this
case? I would like to prevent this.

Any thoughts?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130807/2dcf7f8b/attachment.html>

More information about the Interest mailing list