From 1df39d65f567803929f4b009409f872cd7c46622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 19 Feb 2019 19:50:44 +0100 Subject: [PATCH] Qt: Fix removal of "Capture to a permanent file" setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- capture_opts.c | 1 + ui/qt/capture_interfaces_dialog.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/capture_opts.c b/capture_opts.c index 16d44d1970..8c7e97a516 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -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 */ diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index b9dc86ff9c..f3bdcbab72 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -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();