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.