From a03a43bd320ceeaae9f2dfa2f15213dced579d17 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 29 Jul 2015 10:36:46 -0700 Subject: [PATCH] Capture file retapping fixups. Add CaptureFile::delayedRetapPackets, which starts retapping after the current batch of UI event are processed. Call it in the constructors of various dialogs so that they are shown before tapping starts. This *might* fix a crash found when following large streams from the Conversations dialog. Change-Id: If1b87491621ab7efcc0519f95891d34dcd9d18c1 Reviewed-on: https://code.wireshark.org/review/9818 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/qt/capture_file.cpp | 6 ++++++ ui/qt/capture_file.h | 21 ++++++++++++++++----- ui/qt/conversation_dialog.cpp | 4 ++-- ui/qt/endpoint_dialog.cpp | 2 +- ui/qt/main_window_slots.cpp | 2 +- ui/qt/response_time_delay_dialog.cpp | 2 +- ui/qt/service_response_time_dialog.cpp | 2 +- ui/qt/simple_statistics_dialog.cpp | 2 +- ui/qt/voip_calls_dialog.cpp | 2 +- 9 files changed, 30 insertions(+), 13 deletions(-) diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp index 82a26d1f19..340d3e1e46 100644 --- a/ui/qt/capture_file.cpp +++ b/ui/qt/capture_file.cpp @@ -36,6 +36,7 @@ capture_file cfile; #include "ui/capture.h" #include +#include // To do: // - Add getters and (if needed) setters: @@ -96,6 +97,11 @@ void CaptureFile::retapPackets() } } +void CaptureFile::delayedRetapPackets() +{ + QTimer::singleShot(0, this, SLOT(retapPackets())); +} + void CaptureFile::reload() { if (cap_file_ && cap_file_->state == FILE_READ_DONE) { diff --git a/ui/qt/capture_file.h b/ui/qt/capture_file.h index a4b77fdaaf..430933e76f 100644 --- a/ui/qt/capture_file.h +++ b/ui/qt/capture_file.h @@ -68,10 +68,6 @@ public: */ const QString fileName(); - /** Retap the capture file - */ - void retapPackets(); - /** Re;load the capture file */ void reload(); @@ -107,11 +103,26 @@ signals: void captureCaptureFailed(capture_session *cap_session); public slots: + /** Retap the capture file. Convenience wrapper for cf_retap_packets. + * Application events are processed periodically via update_progress_dlg. + */ + void retapPackets(); + + /** Retap the capture file after the current batch of application events + * is processed. If you call this instead of retapPackets or + * cf_retap_packets in a dialog's constructor it will be displayed before + * tapping starts. + */ + void delayedRetapPackets(); + /** Cancel any tapping that might be in progress. */ void stopLoading(); - // XXX Not used. + /** Sets the capture file's "stop_flag" member. + * + * @param stop_flag If true, stops the current capture file operation. + */ void setCaptureStopFlag(bool stop_flag = true); private: diff --git a/ui/qt/conversation_dialog.cpp b/ui/qt/conversation_dialog.cpp index 545973f77b..e995b63b5e 100644 --- a/ui/qt/conversation_dialog.cpp +++ b/ui/qt/conversation_dialog.cpp @@ -98,7 +98,7 @@ ConversationDialog::ConversationDialog(QWidget &parent, CaptureFile &cf, int cli updateWidgets(); itemSelectionChanged(); - cap_file_.retapPackets(); + cap_file_.delayedRetapPackets(); } ConversationDialog::~ConversationDialog() @@ -228,7 +228,7 @@ void ConversationDialog::followStream() } emit filterAction(filter, FilterAction::ActionApply, FilterAction::ActionTypePlain); - openFollowStreamDialog(ftype); + emit openFollowStreamDialog(ftype); } void ConversationDialog::graphTcp() diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp index db3cce634f..d00341b827 100644 --- a/ui/qt/endpoint_dialog.cpp +++ b/ui/qt/endpoint_dialog.cpp @@ -85,7 +85,7 @@ EndpointDialog::EndpointDialog(QWidget &parent, CaptureFile &cf, int cli_proto_i #endif itemSelectionChanged(); - cap_file_.retapPackets(); + cap_file_.delayedRetapPackets(); } EndpointDialog::~EndpointDialog() diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index be8235c82a..93c6b5943f 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -2528,8 +2528,8 @@ void MainWindow::openFollowStreamDialog(follow_type_t type) { connect(fsd, SIGNAL(updateFilter(QString&, bool)), this, SLOT(filterPackets(QString&, bool))); connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int))); - fsd->follow(getFilter()); fsd->show(); + fsd->follow(getFilter()); } void MainWindow::on_actionAnalyzeFollowTCPStream_triggered() diff --git a/ui/qt/response_time_delay_dialog.cpp b/ui/qt/response_time_delay_dialog.cpp index b250e98a64..8753c3b5c6 100644 --- a/ui/qt/response_time_delay_dialog.cpp +++ b/ui/qt/response_time_delay_dialog.cpp @@ -262,7 +262,7 @@ void ResponseTimeDelayDialog::fillTree() statsTreeWidget()->setSortingEnabled(false); - cf_retap_packets(cap_file_.capFile()); + cap_file_.retapPackets(); tapDraw(&rtd_data); diff --git a/ui/qt/service_response_time_dialog.cpp b/ui/qt/service_response_time_dialog.cpp index 17aba9be5e..407f1ad62b 100644 --- a/ui/qt/service_response_time_dialog.cpp +++ b/ui/qt/service_response_time_dialog.cpp @@ -317,7 +317,7 @@ void ServiceResponseTimeDialog::fillTree() statsTreeWidget()->setSortingEnabled(false); - cf_retap_packets(cap_file_.capFile()); + cap_file_.retapPackets(); // We only have one table. Move its tree items up one level. if (statsTreeWidget()->invisibleRootItem()->childCount() == 1) { diff --git a/ui/qt/simple_statistics_dialog.cpp b/ui/qt/simple_statistics_dialog.cpp index 9de0ace9b3..7a224948bc 100644 --- a/ui/qt/simple_statistics_dialog.cpp +++ b/ui/qt/simple_statistics_dialog.cpp @@ -261,7 +261,7 @@ void SimpleStatisticsDialog::fillTree() reject(); } - cf_retap_packets(cap_file_.capFile()); + cap_file_.retapPackets(); tapDraw(&stat_data); diff --git a/ui/qt/voip_calls_dialog.cpp b/ui/qt/voip_calls_dialog.cpp index 907c885fb3..8aa9f036a6 100644 --- a/ui/qt/voip_calls_dialog.cpp +++ b/ui/qt/voip_calls_dialog.cpp @@ -192,7 +192,7 @@ VoipCallsDialog::VoipCallsDialog(QWidget &parent, CaptureFile &cf, bool all_flow updateWidgets(); tapinfo_.session = cap_file_.capFile()->epan; - cap_file_.retapPackets(); + cap_file_.delayedRetapPackets(); } VoipCallsDialog::~VoipCallsDialog()