From 612fb778f51b704745559345485f4ea44aa71aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 8 May 2018 10:50:00 +0200 Subject: [PATCH] Qt: Update frame selected in several cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that frameSelected(0) is emitted when not having a proto tree field selected because of: 1. No match when trying to restore selected field 2. Search selects a packet with no field to select 3. Current packet is deselected This will disable functionality which requires a selected field and updates the status bar according to selected field. Bug: 14658 Change-Id: I158fae4f26c02f718cee0030ef9e38b597876381 Reviewed-on: https://code.wireshark.org/review/27395 Petri-Dish: Stig Bjørlykke Reviewed-by: Roland Knall Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke --- ui/qt/main_status_bar.cpp | 4 +++- ui/qt/packet_list.cpp | 17 ++++++++++------- ui/qt/proto_tree.cpp | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp index 8fda4a5dac..b3bba9ba78 100644 --- a/ui/qt/main_status_bar.cpp +++ b/ui/qt/main_status_bar.cpp @@ -269,8 +269,10 @@ void MainStatusBar::selectedFieldChanged(FieldInformation * finfo) { QString item_info; - if ( ! finfo ) + if ( ! finfo ) { + pushFieldStatus(item_info); return; + } FieldInformation::HeaderInfo hInfo = finfo->headerInfo(); diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 549f0eaa82..e75cb8b7a5 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -360,7 +360,8 @@ PacketListModel *PacketList::packetListModel() const { return packet_list_model_; } -void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) { +void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) +{ QTreeView::selectionChanged(selected, deselected); if (!cap_file_) return; @@ -388,6 +389,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS if (!cap_file_->edt) { viewport()->update(); + emit fieldSelected(0); return; } @@ -402,9 +404,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS viewport()->update(); } - if (cap_file_->search_in_progress && - (cap_file_->search_pos != 0 || (cap_file_->string && cap_file_->decode_data))) - { + if (cap_file_->search_in_progress) { match_data mdata; field_info *fi = NULL; @@ -414,16 +414,19 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS if (cf_find_string_protocol_tree(cap_file_, cap_file_->edt->tree, &mdata)) { fi = mdata.finfo; } - } else { + } else if (cap_file_->search_pos != 0) { // Find the finfo that corresponds to our byte. fi = proto_find_field_from_offset(cap_file_->edt->tree, cap_file_->search_pos, cap_file_->edt->tvb); } if (fi) { - emit fieldSelected(new FieldInformation(fi, this)); + FieldInformation finfo(fi, this); + emit fieldSelected(&finfo); + } else { + emit fieldSelected(0); } - } else if (!cap_file_->search_in_progress && proto_tree_) { + } else if (proto_tree_) { proto_tree_->restoreSelectedField(); } } diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 26ffa2d38a..8b53332039 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -478,7 +478,9 @@ void ProtoTree::restoreSelectedField() cur_index = proto_tree_model_->index(row, 0, cur_index); FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(cur_index).protoNode()); if (!finfo.isValid() || finfo.headerInfo().id != hf_id) { + // Did not find the selected hfid path in the selected packet cur_index = QModelIndex(); + emit fieldSelected(0); break; } }