diff options
author | Gerald Combs <gerald@wireshark.org> | 2014-10-31 15:49:04 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2014-10-31 22:53:53 +0000 |
commit | 5a71cfddf3cb659f161f74dc9b81e39adfad40ab (patch) | |
tree | b99dd8acc0774a3f1e41cc32ce078524320e217a /ui | |
parent | 065d2b716d0f82fcaf928177dd27021305197c68 (diff) |
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 <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/follow_stream_dialog.cpp | 31 | ||||
-rw-r--r-- | ui/qt/follow_stream_dialog.h | 1 |
2 files changed, 28 insertions, 4 deletions
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 <QKeyEvent> #include <QMessageBox> #include <QPrintDialog> @@ -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<int, guint32>::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); |