Qt: Fix removal of "Capture to a permanent file" setting

Make it possible to remove the "Capture to a permanent file" setting
in Capture Interfaces Output dialog by turning off saving_to_file in
updateInterfaces().

Also make sure to free the old values for save_file and orig_save_file
to avoid memory leaks.

Set orig_save_file to the same as save_file from the '-w' option to
fill in the current "Capture to a permanent file" value correctly.

Change-Id: I1f4df8cfa279f934eff028f32838b9734b627af1
Reviewed-on: https://code.wireshark.org/review/32111
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Stig Bjørlykke 2019-02-19 19:50:44 +01:00 committed by Anders Broman
parent efe920af3a
commit 1df39d65f5
2 changed files with 6 additions and 0 deletions

View File

@ -935,6 +935,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
capture_opts->saving_to_file = TRUE;
g_free(capture_opts->save_file);
capture_opts->save_file = g_strdup(optarg_str_p);
capture_opts->orig_save_file = g_strdup(optarg_str_p);
status = capture_opts_output_to_pipe(capture_opts->save_file, &capture_opts->output_to_pipe);
return status;
case 'y': /* Set the pcap data link type */

View File

@ -817,6 +817,9 @@ bool CaptureInterfacesDialog::saveOptionsToPreferences()
prefs.capture_pcap_ng = false;
}
g_free(global_capture_opts.save_file);
g_free(global_capture_opts.orig_save_file);
QString filename = ui->filenameLineEdit->text();
if (filename.length() > 0) {
/* User specified a file to which the capture should be written. */
@ -827,7 +830,9 @@ bool CaptureInterfacesDialog::saveOptionsToPreferences()
set_last_open_dir(get_dirname(filename.toUtf8().data()));
} else {
/* User didn't specify a file; save to a temporary file. */
global_capture_opts.saving_to_file = false;
global_capture_opts.save_file = NULL;
global_capture_opts.orig_save_file = NULL;
}
global_capture_opts.has_ring_num_files = ui->RbCheckBox->isChecked();