Qt: highlight when search result is in the current packet.

Calling setCurrentIndex with QItemSelectionModel::ClearAndSelect clears
the currentIndex, but not the selection, so it doesn't trigger
selectionChanged. However, highlighting depends on the selectionChanged
signal, not currentChanged(), and it's not emitted if we're still on the
same packet/row as the current selection (which can occur if searching
for something that occurs in exactly one packet in a capture.)

Since packet_list_select_row_from_data() cares about where the data
is within the packet, it needs to clear the selection.  Fix #8269
This commit is contained in:
John Thacker 2022-02-09 22:32:59 -05:00 committed by A Wireshark GitLab Utility
parent 0011bb6a4c
commit 52955b9c43
1 changed files with 7 additions and 0 deletions

View File

@ -132,6 +132,13 @@ packet_list_select_row_from_data(frame_data *fdata_needle)
model->flushVisibleRows();
int row = model->visibleIndexOf(fdata_needle);
if (row >= 0) {
/* Calling ClearAndSelect with setCurrentIndex clears the "current"
* item, but doesn't clear the "selected" item. We want to clear
* the "selected" item as well so that selectionChanged() will be
* emitted in order to force an update of the packet details and
* packet bytes after a search.
*/
gbl_cur_packet_list->selectionModel()->clearSelection();
gbl_cur_packet_list->selectionModel()->setCurrentIndex(model->index(row, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
return TRUE;
}