new_packet_list_find_row_from_data() is always used to select a packet,
so get rid of the select_flag argument, and rename it new_packet_list_select_row_from_data(). It's also always passed a frame_data *, so make its argument a frame_data *. Its return value is used only to detect whether the packet was found in the display or not, so make it a gboolean. Check it in *all* cases where it's called, and change the dialog message a bit (the most likely cause is that the user cancelled a redissection of the packets, so not all packets in the capture file are in the display. Also, in the find case, pass it the new packet we found. svn path=/trunk/; revision=36839
This commit is contained in:
parent
b99f04d32c
commit
a39c3fab30
35
file.c
35
file.c
|
@ -1923,7 +1923,15 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
|||
if (selected_frame_num == 0) {
|
||||
new_packet_list_select_first_row();
|
||||
}else{
|
||||
new_packet_list_find_row_from_data(selected_frame, TRUE);
|
||||
if (!new_packet_list_select_row_from_data(selected_frame)) {
|
||||
/* We didn't find a row corresponding to this frame.
|
||||
This means that the frame isn't being displayed currently,
|
||||
so we can't select it. */
|
||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||
"%sEnd of capture exceeded!%s\n\n"
|
||||
"The capture file is probably not fully dissected.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3214,7 +3222,7 @@ find_packet(capture_file *cf,
|
|||
progdlg_t *progbar = NULL;
|
||||
gboolean stop_flag;
|
||||
int count;
|
||||
int row;
|
||||
gboolean found;
|
||||
float progbar_val;
|
||||
GTimeVal start_time;
|
||||
gchar status_str[100];
|
||||
|
@ -3357,16 +3365,16 @@ find_packet(capture_file *cf,
|
|||
if (new_fd != NULL) {
|
||||
/* Find and select */
|
||||
cf->search_in_progress = TRUE;
|
||||
row = new_packet_list_find_row_from_data(fdata, TRUE);
|
||||
found = new_packet_list_select_row_from_data(new_fd);
|
||||
cf->search_in_progress = FALSE;
|
||||
cf->search_pos = 0; /* Reset the position */
|
||||
if (row == -1) {
|
||||
/* We didn't find a row even though we know that a frame
|
||||
* exists that satifies the search criteria. This means that the
|
||||
* frame isn't being displayed currently so we can't select it. */
|
||||
if (!found) {
|
||||
/* We didn't find a row corresponding to this frame.
|
||||
This means that the frame isn't being displayed currently,
|
||||
so we can't select it. */
|
||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||
"%sEnd of capture exceeded!%s\n\n"
|
||||
"The capture file is probably not fully loaded.",
|
||||
"The capture file is probably not fully dissected.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3395,7 +3403,16 @@ cf_goto_frame(capture_file *cf, guint fnumber)
|
|||
return FALSE; /* we failed to go to that packet */
|
||||
}
|
||||
|
||||
new_packet_list_find_row_from_data(fdata, TRUE);
|
||||
if (!new_packet_list_select_row_from_data(fdata)) {
|
||||
/* We didn't find a row corresponding to this frame.
|
||||
This means that the frame isn't being displayed currently,
|
||||
so we can't select it. */
|
||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||
"%sEnd of capture exceeded!%s\n\n"
|
||||
"The capture file is probably not fully dissected.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE; /* we got to that packet */
|
||||
}
|
||||
|
||||
|
|
|
@ -1134,18 +1134,22 @@ new_packet_list_check_end(void)
|
|||
return at_end;
|
||||
}
|
||||
|
||||
gint
|
||||
new_packet_list_find_row_from_data(gpointer data, gboolean select_flag)
|
||||
/*
|
||||
* Given a frame_data structure, scroll to and select the row in the
|
||||
* packet list corresponding to that frame. If there is no such
|
||||
* row, return FALSE, otherwise return TRUE.
|
||||
*/
|
||||
gboolean
|
||||
new_packet_list_select_row_from_data(frame_data *fdata_needle)
|
||||
{
|
||||
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
||||
GtkTreeIter iter;
|
||||
frame_data *fdata_needle = data;
|
||||
|
||||
/* Initializes iter with the first iterator in the tree (the one at the path "0")
|
||||
* and returns TRUE. Returns FALSE if the tree is empty
|
||||
*/
|
||||
if(!gtk_tree_model_get_iter_first(model, &iter))
|
||||
return -1;
|
||||
return FALSE;
|
||||
|
||||
do {
|
||||
PacketListRecord *record;
|
||||
|
@ -1155,14 +1159,13 @@ new_packet_list_find_row_from_data(gpointer data, gboolean select_flag)
|
|||
fdata = record->fdata;
|
||||
|
||||
if(fdata == fdata_needle) {
|
||||
if(select_flag)
|
||||
scroll_to_and_select_iter(model, NULL, &iter);
|
||||
scroll_to_and_select_iter(model, NULL, &iter);
|
||||
|
||||
return fdata->num;
|
||||
return TRUE;
|
||||
}
|
||||
} while (gtk_tree_model_iter_next(model, &iter));
|
||||
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -71,7 +71,7 @@ void new_packet_list_select_first_row(void);
|
|||
void new_packet_list_select_last_row(void);
|
||||
void new_packet_list_moveto_end(void);
|
||||
gboolean new_packet_list_check_end(void);
|
||||
gint new_packet_list_find_row_from_data(gpointer data, gboolean select);
|
||||
gboolean new_packet_list_select_row_from_data(frame_data *fdata_needle);
|
||||
void new_packet_list_resize_column(gint col);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue