From 5a71cfddf3cb659f161f74dc9b81e39adfad40ab Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 31 Oct 2014 15:49:04 -0700 Subject: Qt: Disable our widgets while tapping. Prevents a crash when changing the spinbox value during the middle of a follow. Change-Id: I07cea883c72c5975633e4b7046155f9b6de9cc4a Reviewed-on: https://code.wireshark.org/review/5034 Reviewed-by: Gerald Combs --- ui/qt/follow_stream_dialog.cpp | 31 +++++++++++++++++++++++++++---- ui/qt/follow_stream_dialog.h | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index f6964c299c..86f63b17bf 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -51,6 +51,8 @@ #include "ui/follow.h" +#include "wireshark_application.h" + #include #include #include @@ -61,7 +63,9 @@ // To do: // - Instead of calling QMessageBox, display the error message in the text // box and disable the appropriate controls. -// add stream number for UDP. +// - Add stream number for UDP. +// - Draw text by hand similar to ByteViewText. This would let us add +// extra information, e.g. a timestamp column. FollowStreamDialog::FollowStreamDialog(QWidget *parent, follow_type_t type, capture_file *cf) : QDialog(parent), @@ -158,6 +162,9 @@ void FollowStreamDialog::fillHintLabel(int text_pos) void FollowStreamDialog::goToPacketForTextPos(int text_pos) { int pkt = -1; + if (!cap_file_) { + return; + } if (text_pos >= 0) { QMap::iterator it = text_pos_to_packet_.upperBound(text_pos); @@ -171,6 +178,22 @@ void FollowStreamDialog::goToPacketForTextPos(int text_pos) } } +void FollowStreamDialog::updateWidgets(bool enable) +{ + if (!cap_file_) { + enable = false; + ui->streamNumberSpinBox->setToolTip(QString()); + ui->streamNumberLabel->setToolTip(QString()); + } + ui->teStreamContent->setEnabled(enable); + ui->cbDirections->setEnabled(enable); + ui->cbCharset->setEnabled(enable); + ui->streamNumberSpinBox->setEnabled(enable); + ui->leFind->setEnabled(enable); + ui->bFind->setEnabled(enable); + b_filter_out_->setEnabled(enable); +} + void FollowStreamDialog::findText(bool go_back) { if (ui->leFind->text().isEmpty()) return; @@ -259,8 +282,10 @@ void FollowStreamDialog::on_leFind_returnPressed() void FollowStreamDialog::on_streamNumberSpinBox_valueChanged(int stream_num) { if (stream_num >= 0) { + updateWidgets(false); follow_tcp_index(stream_num); follow(QString(), true); + updateWidgets(); } } @@ -550,10 +575,8 @@ void FollowStreamDialog::setCaptureFile(capture_file *cf) { if (!cf) { // We only want to know when the file closes. cap_file_ = NULL; - ui->streamNumberSpinBox->setEnabled(false); - ui->streamNumberSpinBox->setToolTip(QString()); - ui->streamNumberLabel->setToolTip(QString()); } + updateWidgets(); } // The following keyboard shortcuts should work (although diff --git a/ui/qt/follow_stream_dialog.h b/ui/qt/follow_stream_dialog.h index fef1e45f41..6ffeb7274b 100644 --- a/ui/qt/follow_stream_dialog.h +++ b/ui/qt/follow_stream_dialog.h @@ -102,6 +102,7 @@ signals: private: void removeStreamControls(); void resetStream(void); + void updateWidgets(bool enable = true); frs_return_t follow_show(char *buffer, size_t nchars, gboolean is_from_server, guint32 packet_num, guint32 *global_pos); -- cgit v1.2.3