From 17cd230a03da48667372b758a71534b9508bfa0d Mon Sep 17 00:00:00 2001 From: Jirka Novak Date: Sun, 5 Jan 2020 23:33:04 +0100 Subject: voip_calls_dialog: avoiding of 'remove_tap_listener(): no listener ...' warning When voip_calls_dialog is opened and then closed, mentioned warning is shown because voip_calls_remove_all_tap_listeners is called twice in two different methods. Removing of the call from one of method is not possible therefore I introduced variable which tracks whether voip_calls_remove_all_tap_listeners was already called or not. Change-Id: Ic3c206cb7baf6612958d383880af296af019ffd8 Reviewed-on: https://code.wireshark.org/review/35660 Petri-Dish: Jim Young Tested-by: Petri Dish Buildbot Reviewed-by: Jim Young Reviewed-by: Alexis La Goutte --- ui/qt/voip_calls_dialog.cpp | 18 ++++++++++++++---- ui/qt/voip_calls_dialog.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/qt/voip_calls_dialog.cpp b/ui/qt/voip_calls_dialog.cpp index 09767b55c9..3806825a7e 100644 --- a/ui/qt/voip_calls_dialog.cpp +++ b/ui/qt/voip_calls_dialog.cpp @@ -44,7 +44,8 @@ enum { voip_calls_type_ = 1000 }; VoipCallsDialog::VoipCallsDialog(QWidget &parent, CaptureFile &cf, bool all_flows) : WiresharkDialog(parent, cf), ui(new Ui::VoipCallsDialog), - parent_(parent) + parent_(parent), + voip_calls_tap_listeners_removed_(false) { ui->setupUi(this); loadGeometry(parent.width() * 4 / 5, parent.height() * 2 / 3); @@ -104,14 +105,20 @@ VoipCallsDialog::~VoipCallsDialog() delete ui; voip_calls_reset_all_taps(&tapinfo_); - voip_calls_remove_all_tap_listeners(&tapinfo_); + if (!voip_calls_tap_listeners_removed_) { + voip_calls_remove_all_tap_listeners(&tapinfo_); + voip_calls_tap_listeners_removed_ = true; + } sequence_info_->unref(); g_queue_free(tapinfo_.callsinfos); } void VoipCallsDialog::removeTapListeners() { - voip_calls_remove_all_tap_listeners(&tapinfo_); + if (!voip_calls_tap_listeners_removed_) { + voip_calls_remove_all_tap_listeners(&tapinfo_); + voip_calls_tap_listeners_removed_ = true; + } WiresharkDialog::removeTapListeners(); } @@ -121,7 +128,10 @@ void VoipCallsDialog::captureFileClosing() // the cache is active, the ToD cannot be modified. ui->todCheckBox->setEnabled(false); cache_model_->setSourceModel(NULL); - voip_calls_remove_all_tap_listeners(&tapinfo_); + if (!voip_calls_tap_listeners_removed_) { + voip_calls_remove_all_tap_listeners(&tapinfo_); + voip_calls_tap_listeners_removed_ = true; + } tapinfo_.session = NULL; WiresharkDialog::captureFileClosing(); } diff --git a/ui/qt/voip_calls_dialog.h b/ui/qt/voip_calls_dialog.h index 4b9d163038..f1bf5c5efb 100644 --- a/ui/qt/voip_calls_dialog.h +++ b/ui/qt/voip_calls_dialog.h @@ -65,6 +65,7 @@ private: QPushButton *sequence_button_; QPushButton *player_button_; QPushButton *copy_button_; + bool voip_calls_tap_listeners_removed_; // Tap callbacks // static void tapReset(void *tapinfo_ptr); -- cgit v1.2.3