From 0088d010edb1dc9704efa1ad11e7d0975b6878ba Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 20 Oct 2017 03:43:03 +0100 Subject: Qt: fix crash after loading SRT dialog TapParameterDialog::on_applyFilterButton_clicked first calls fillTree to populate the table and endRetapPackets to add the results to GUI. The table data must remain valid until closing the dialog since the user can still interact with the GUI. Change-Id: Ie3105be78d39c562af52f2b49081552063afcada Ping-Bug: 14141 Reviewed-on: https://code.wireshark.org/review/23994 Reviewed-by: Pascal Quantin Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- ui/qt/service_response_time_dialog.cpp | 15 ++++++++++++--- ui/qt/service_response_time_dialog.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ui/qt/service_response_time_dialog.cpp b/ui/qt/service_response_time_dialog.cpp index 1e142efea9..b79ce7fd10 100644 --- a/ui/qt/service_response_time_dialog.cpp +++ b/ui/qt/service_response_time_dialog.cpp @@ -210,6 +210,14 @@ ServiceResponseTimeDialog::ServiceResponseTimeDialog(QWidget &parent, CaptureFil this, SLOT(statsTreeWidgetItemChanged())); } +ServiceResponseTimeDialog::~ServiceResponseTimeDialog() +{ + if (srt_data_.srt_array) { + free_srt_table(srt_, srt_data_.srt_array, NULL, NULL); + g_array_free(srt_data_.srt_array, TRUE); + } +} + TapParameterDialog *ServiceResponseTimeDialog::createSrtDialog(QWidget &parent, const QString cfg_str, const QString filter, CaptureFile &cf) { if (!cfg_str_to_srt_.contains(cfg_str)) { @@ -269,6 +277,10 @@ void ServiceResponseTimeDialog::endRetapPackets() void ServiceResponseTimeDialog::fillTree() { + if (srt_data_.srt_array) { + free_srt_table(srt_, srt_data_.srt_array, NULL, NULL); + g_array_free(srt_data_.srt_array, TRUE); + } srt_data_.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*)); srt_data_.user_data = this; @@ -301,9 +313,6 @@ void ServiceResponseTimeDialog::fillTree() statsTreeWidget()->setSortingEnabled(true); removeTapListeners(); - - free_srt_table(srt_, srt_data_.srt_array, NULL, NULL); - g_array_free(srt_data_.srt_array, TRUE); } QList ServiceResponseTimeDialog::treeItemData(QTreeWidgetItem *ti) const diff --git a/ui/qt/service_response_time_dialog.h b/ui/qt/service_response_time_dialog.h index f3273ac6ea..ec953eb423 100644 --- a/ui/qt/service_response_time_dialog.h +++ b/ui/qt/service_response_time_dialog.h @@ -36,6 +36,7 @@ class ServiceResponseTimeDialog : public TapParameterDialog public: ServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, struct register_srt *srt, const QString filter, int help_topic = 0); + ~ServiceResponseTimeDialog(); static TapParameterDialog *createSrtDialog(QWidget &parent, const QString cfg_str, const QString filter, CaptureFile &cf); public slots: -- cgit v1.2.3