Qt: Fix packet deselection.

When no packets are selected, clear the related item delegate, packet
detail, and byte view. Also, don't crash.

Bug: 10529
Change-Id: I1f46d0d60d060d517f1ee2f8b5a9124bc1fad00e
Reviewed-on: https://code.wireshark.org/review/8470
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-05-15 09:04:02 -07:00
parent f1a747e96e
commit 76a5465cf0
1 changed files with 14 additions and 5 deletions

View File

@ -452,12 +452,23 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
if (!cap_file_) return;
int row = selected.first().top();
cf_select_packet(cap_file_, row);
if (selected.isEmpty()) {
cf_unselect_packet(cap_file_);
} else {
int row = selected.first().top();
cf_select_packet(cap_file_, row);
}
related_packet_delegate_.clear();
if (proto_tree_) proto_tree_->clear();
if (byte_view_tab_) byte_view_tab_->clear();
emit packetSelectionChanged();
if (!cap_file_->edt) return;
if (!cap_file_->edt) {
viewport()->update();
return;
}
if (proto_tree_ && cap_file_->edt->tree) {
packet_info *pi = &cap_file_->edt->pi;
@ -476,8 +487,6 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
struct data_source *source;
char* source_name;
byte_view_tab_->clear();
for (src_le = cap_file_->edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
source = (struct data_source *)src_le->data;
source_name = get_data_source_name(source);