Don't hide dialogs before closing them
When a dialog was accepted or rejected via done(), we used to only hide
it, but as of 0246bfd40a
we now close it.
Closing a widget results in hiding it as part of handleClose, so we
do not need to explicitly hide it before calling close(). In fact
doing so prevents the lastWindowClosed logic from checking whether
the window was visible before handling the close event, which is
documented to be a requirement for a window triggering lastWindowClosed.
We still need to hide the widget in case we don't end up closing it
ourselves, to ensure QDialog::closeEvent accepts the close. The reason
for the code in closeEvent seems a bit dubious, but that's left for
future adventures.
Change-Id: Ic32b965d495c08996c3a199bbee798df0206216c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
df359bcb70
commit
44b7a1a37b
@ -153,7 +153,7 @@ void QDialogPrivate::close(int resultCode)
|
||||
Q_Q(QDialog);
|
||||
|
||||
q->setResult(resultCode);
|
||||
q->hide();
|
||||
|
||||
if (!data.is_closing) {
|
||||
// Until Qt 6.3 we didn't close dialogs, so they didn't receive a QCloseEvent.
|
||||
// It is likely that subclasses implement closeEvent and handle them as rejection
|
||||
@ -171,6 +171,12 @@ void QDialogPrivate::close(int resultCode)
|
||||
} closeEventEater;
|
||||
q->installEventFilter(&closeEventEater);
|
||||
QWidgetPrivate::close();
|
||||
} else {
|
||||
// If the close was initiated outside of QDialog we will end up
|
||||
// here via QDialog::closeEvent calling reject(), in which case
|
||||
// we need to hide the dialog to ensure QDialog::closeEvent does
|
||||
// not ignore the close event. FIXME: Why is QDialog doing this?
|
||||
q->hide();
|
||||
}
|
||||
|
||||
resetModalitySetByOpen();
|
||||
|
Loading…
Reference in New Issue
Block a user