Try to fix bug #6208: Status bar count of displayed packets wrong
authorJakub Zawadzki <darkjames-ws@darkjames.pl>
Thu, 27 Sep 2012 20:59:54 +0000 (20:59 -0000)
committerJakub Zawadzki <darkjames-ws@darkjames.pl>
Thu, 27 Sep 2012 20:59:54 +0000 (20:59 -0000)
When refiltering we process gtk/glib events, so it's possible that cf_continue_tail()
will fire-up, reading new packets and incrementing cf->count.

It's also possible that this packet(s) will pass display filter,
incrementing cf->displayed_count.

But when refiltering we use cf->count as number of packets to process, so
new packets are also processed, incrementing cf->displayed_count second time.

Fix bug by saving cf->count before starting refilter loop.

svn path=/trunk/; revision=45182

file.c

diff --git a/file.c b/file.c
index cf7e4a7da13be7a676ccc857d3dc216a503b7d5f..da9fba152cfb10ef0fab673d8652f557d46cc47b 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1776,6 +1776,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
   guint       tap_flags;
   gboolean    add_to_packet_list = FALSE;
   gboolean    compiled;
+  guint32     frames_count;
 
   /* Compile the current display filter.
    * We assume this will not fail since cf->dfilter is only set in
@@ -1864,7 +1865,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
 
   selected_frame_seen = FALSE;
 
-  for (framenum = 1; framenum <= cf->count; framenum++) {
+  frames_count = cf->count;
+  for (framenum = 1; framenum <= frames_count; framenum++) {
     fdata = frame_data_sequence_find(cf->frames, framenum);
 
     /* Create the progress bar if necessary.
@@ -1887,11 +1889,11 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
        * with count == 0, so let's assert that
        */
       g_assert(cf->count > 0);
-      progbar_val = (gfloat) count / cf->count;
+      progbar_val = (gfloat) count / frames_count;
 
       if (progbar != NULL) {
         g_snprintf(status_str, sizeof(status_str),
-                  "%4u of %u frames", count, cf->count);
+                  "%4u of %u frames", count, frames_count);
         update_progress_dlg(progbar, progbar_val, status_str);
       }
 
@@ -1980,7 +1982,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
        even though the user requested that the scan stop, and that
        would leave the user stuck with an Wireshark grinding on
        until it finishes.  Should we just stick them with that? */
-    for (; framenum <= cf->count; framenum++) {
+    for (; framenum <= frames_count; framenum++) {
       fdata = frame_data_sequence_find(cf->frames, framenum);
       fdata->flags.visited = 0;
       frame_data_cleanup(fdata);