If any input events are sent to a window while QApplication::processEvents(QEventLoop::ExcludeUserInputEvents) is being used, and that window gets destroyed, the queued events will be sent later to the stale window.
I've been trying to track down this problem in our commercial application for a while, with no luck. Finally I was able to repeat it and track down the cause.
I am attaching a sample application and a stack trace that show the problem. For the sample application, press the button and move the mouse around the progress dialog. The application will crash after it closes.
|For Gerrit Dashboard: QTBUG-39211|
|86098,1||Cocoa: clear queued user input events when window is destroyed||stable||qt/qtbase||Status: ABANDONED||0||0|
|86099,4||Cocoa: clear queued user input events when window is destroyed||stable||qt/qtbase||Status: MERGED||+2||0|
|198524,4||macOS: Remove workaround for queued input events to stale windows||dev||qt/qtbase||Status: MERGED||+2||0|