diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-04-28 15:53:18 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-05-01 10:24:47 +0000 |
commit | 4d2844cceca4fdde1e293e3f404f8e820d2385b0 (patch) | |
tree | 90ae1b1c7c11875424c5981e2008e2da52267f32 /ui/qt/capture_file_dialog.cpp | |
parent | 552ef8b1f4bc5ced263c82253ed21793ca8e5d5e (diff) |
Qt: do not further modify filename from Save dialog
Let the Save dialog fixup the extension on accepting the dialog.
Otherwise it is possible that files are silently overwritten without
prompting. Additionally, if a user decides to save a pcapng file as
"foo.pcap", do not try to rename it to "foo.pcap.pcapng".
This change is limited to macOS and Linux because Windows uses a
different file dialog. Tested with both macOS and Linux.
Bug: 14600
Change-Id: Ie0bc1f579766a04f0aad96dcd5daba3fffef9764
Reviewed-on: https://code.wireshark.org/review/27188
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/capture_file_dialog.cpp')
-rw-r--r-- | ui/qt/capture_file_dialog.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp index 90719d6a3e..852b2150a7 100644 --- a/ui/qt/capture_file_dialog.cpp +++ b/ui/qt/capture_file_dialog.cpp @@ -217,6 +217,21 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget * } +#ifndef Q_OS_WIN +void CaptureFileDialog::accept() +{ + // XXX also useful for Windows, but that uses a different dialog... + // Ensure that the filename has a valid extension before performing file + // existence checks and before closing the dialog. + // HACK: ensure that the filename field does not have the focus, otherwise + // selectFile will not change the filename. + setFocus(); + fixFilenameExtension(); + QFileDialog::accept(); +} +#endif // ! Q_OS_WIN + + // You have to use open, merge, saveAs, or exportPackets. We should // probably just make each type a subclass. int CaptureFileDialog::exec() { |