diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-01-03 03:46:36 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-01-03 03:46:36 +0000 |
commit | 04e20bf4cd34fd3587e48e93acad8e0e9ea21d4c (patch) | |
tree | b4dc19458df1d5a9d8eb084b64f509b31e3ade8a | |
parent | d6c6aecdba0990128aeb8a047322e12b539c1bca (diff) |
Fix a nasty side-effect of running the packet list in
GTK_SELECTION_BROWSE mode - that mode apparently always arranges that
there is (in a non-empty GtkCList) one row selected, which means that
when the first row is added, it selects it.
Unfortunately, that causes a "select-row" signal to be emitted, which
causes "select_packet()" to be called - but we haven't yet set "fd->row"
for the frame we're adding, so "select_packet()" can't find the frame
for the row being selected, and it aborts.
This causes a core dump when the first packet arrives during an "Update
list of packets in real time" capture.
For now, we handle this by, if we don't find the frame with the given
row number, checking that there's exactly one frame in our list of
frames and, if so, saying that frame is the frame for which we're
looking.
svn path=/trunk/; revision=1409
-rw-r--r-- | file.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.143 1999/12/29 20:09:45 gram Exp $ + * $Id: file.c,v 1.144 2000/01/03 03:46:36 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -1207,13 +1207,37 @@ select_packet(capture_file *cf, int row) int i; /* Search through the list of frames to see which one is in - this row. */ + this row. + + XXX - if a GtkCList's selection mode is GTK_SELECTION_BROWSE, when + the first entry is added to it by "real_insert_row()", that row + is selected (see "real_insert_row()", in "gtk/gtkclist.c", in both + our version and the vanilla GTK+ version). + + This means that a "select-row" signal is emitted; this causes + "packet_list_select_cb()" to be called, which causes "select_packet()" + to be called. + + As "gtk_clist_append()", which called "real_insert_row()", hasn't + yet returned, we don't know what the row number is, so we can't + set "fd->row" for that frame yet. + + This means that we won't find this row in the list of frames. + + For now, we handle that by, if "fd" is NULL when the loop terminates + (meaning we didn't find the frame), verifying that "i" is 1 (meaning + there's only one frame in the list, which we take as a sign that the + first and only frame *must* have been the one selected) and forcibly + setting "fd" to "cf->plist" (so that it points to the first and only + frame). */ for (fd = cf->plist, i = 0; fd != NULL; fd = fd->next, i++) { if (fd->row == row) break; } - - g_assert(fd != NULL); + if (fd == NULL) { + g_assert(i == 1); + fd = cf->plist; + } /* Record that this frame is the current frame, and that it's selected. */ cf->current_frame = fd; |