Qt: Make the checkSaveAsWithComment dialog box appear.

Set the parent of the QMessageBox in the constructor instead of calling
QMessageBox::setParent(). The latter inherits from QDialog, and it
"clear[s] the window flags specifying the window-system properties for
the widget (in particular it will reset the Qt::Dialog flag)."
(See https://doc.qt.io/qt-5/qdialog.html#details )
This makes the dialog properly appear instead of attempting to save a file
with comments to a file type that does not support comments silently failing.
Fixes #17146.
This commit is contained in:
John Thacker 2021-01-11 19:11:52 -05:00 committed by AndersBroman
parent ab42a5dc41
commit fb422bed91
1 changed files with 1 additions and 2 deletions

View File

@ -117,11 +117,10 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *parent, c
return SAVE;
}
QMessageBox msg_dialog;
QMessageBox msg_dialog(parent);
QPushButton *save_button;
QPushButton *discard_button;
msg_dialog.setParent(parent);
msg_dialog.setIcon(QMessageBox::Question);
msg_dialog.setText(tr("This capture file contains comments."));
msg_dialog.setStandardButtons(QMessageBox::Cancel);