Don't call QApplication::processEvents to update size hint
The current code calls setSizePolicy and then resizes the dialog to the sizeHint.
However sizeHint is only updated asynchronously, so we use QApplication::processEvents to force that.
Processing the events this way can cause unforseen havoc, in particular it causes dialogs that use WA_DeleteOnClose to be closed too early, causing crashes.
Instead of force processing the events delay the setting of the new size one event loop iteration