Check on every iteration of a loop whether to pop up a dialog box,
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 27 Oct 2005 06:45:37 +0000 (06:45 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 27 Oct 2005 06:45:37 +0000 (06:45 +0000)
rather than checking only on every progress bar update quantum, so that
if the update quantum is *very* large, we don't end up waiting longer
than the standard time for a dialog box before checking.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16327 f5534014-38df-0310-8fa8-9805f1628bb7

file.c
gtk/packet_list.c
gtk/proto_draw.c
proto_hier_stats.c

diff --git a/file.c b/file.c
index a555092ec15b251fd8874ef49b963f52d7e70df1..a10a835744063cb29c504ed03862c96795effa4e 100644 (file)
--- a/file.c
+++ b/file.c
@@ -409,6 +409,16 @@ cf_read(capture_file *cf)
 
   while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
     if (size >= 0) {
+      /* Create the progress bar if necessary.
+         We check on every iteration of the loop, so that it takes no
+         longer than the standard time to create it (otherwise, for a
+         large file, we might take considerably longer than that standard
+         time in order to get to the next progress bar step). */
+      if (progbar == NULL) {
+        progbar = delayed_create_progress_dlg("Loading", name_ptr,
+          &stop_flag, &start_time, prog_val);
+      }
+
       /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
          when we update it, we have to run the GTK+ main loop to get it
          to repaint what's pending, and doing so may involve an "ioctl()"
@@ -430,11 +440,6 @@ cf_read(capture_file *cf)
             if (prog_val > 1.0)
               prog_val = 1.0;
           }
-          if (progbar == NULL) {
-            /* Create the progress bar if necessary */
-            progbar = delayed_create_progress_dlg("Loading", name_ptr,
-              &stop_flag, &start_time, prog_val);
-          }
           if (progbar != NULL) {
             g_snprintf(status_str, sizeof(status_str),
                        "%" PRId64 "KB of %" PRId64 "KB",
@@ -1044,6 +1049,21 @@ cf_merge_files(char **out_filenamep, int in_file_count,
     for (i = 0; i < in_file_count; i++)
       data_offset += in_files[i].data_offset;
 
+    /* Create the progress bar if necessary.
+       We check on every iteration of the loop, so that it takes no
+       longer than the standard time to create it (otherwise, for a
+       large file, we might take considerably longer than that standard
+       time in order to get to the next progress bar step). */
+    if (progbar == NULL) {
+      progbar = delayed_create_progress_dlg("Merging", "files",
+        &stop_flag, &start_time, prog_val);
+    }
+
+    /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
+       when we update it, we have to run the GTK+ main loop to get it
+       to repaint what's pending, and doing so may involve an "ioctl()"
+       to see if there's any pending input from an X server, and doing
+       that for every packet can be costly, especially on a big file. */
     if (data_offset >= progbar_nextstep) {
         /* Get the sum of the seek positions in all of the files. */
         file_pos = 0;
@@ -1056,11 +1076,6 @@ cf_merge_files(char **out_filenamep, int in_file_count,
              value at 1.0. */
           prog_val = 1.0;
         }
-        if (progbar == NULL) {
-          /* Create the progress bar if necessary */
-          progbar = delayed_create_progress_dlg("Merging", "files",
-            &stop_flag, &start_time, prog_val);
-        }
         if (progbar != NULL) {
           g_snprintf(status_str, sizeof(status_str),
                      "%" PRId64 "KB of %" PRId64 "KB",
@@ -1327,6 +1342,15 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
   selected_frame_seen = FALSE;
 
   for (fdata = cf->plist; fdata != NULL; fdata = fdata->next) {
+    /* Create the progress bar if necessary.
+       We check on every iteration of the loop, so that it takes no
+       longer than the standard time to create it (otherwise, for a
+       large file, we might take considerably longer than that standard
+       time in order to get to the next progress bar step). */
+    if (progbar == NULL)
+      progbar = delayed_create_progress_dlg(action, action_item, &stop_flag,
+        &start_time, prog_val);
+
     /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
        when we update it, we have to run the GTK+ main loop to get it
        to repaint what's pending, and doing so may involve an "ioctl()"
@@ -1339,11 +1363,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
       g_assert(cf->count > 0);
       prog_val = (gfloat) count / cf->count;
 
-      if (progbar == NULL)
-        /* Create the progress bar if necessary */
-        progbar = delayed_create_progress_dlg(action, action_item, &stop_flag,
-          &start_time, prog_val);
-
       if (progbar != NULL) {
         g_snprintf(status_str, sizeof(status_str),
                   "%4u of %u frames", count, cf->count);
@@ -1545,6 +1564,17 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
   /* Iterate through the list of packets, printing the packets that
      were selected by the current display filter.  */
   for (fdata = cf->plist; fdata != NULL; fdata = fdata->next) {
+    /* Create the progress bar if necessary.
+       We check on every iteration of the loop, so that it takes no
+       longer than the standard time to create it (otherwise, for a
+       large file, we might take considerably longer than that standard
+       time in order to get to the next progress bar step). */
+    if (progbar == NULL)
+      progbar = delayed_create_progress_dlg(string1, string2,
+                                            &progbar_stop_flag,
+                                            &progbar_start_time,
+                                            progbar_val);
+
     /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
        when we update it, we have to run the GTK+ main loop to get it
        to repaint what's pending, and doing so may involve an "ioctl()"
@@ -1557,13 +1587,6 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
       g_assert(cf->count > 0);
       progbar_val = (gfloat) progbar_count / cf->count;
 
-      if (progbar == NULL)
-        /* Create the progress bar if necessary */
-        progbar = delayed_create_progress_dlg(string1, string2,
-                                              &progbar_stop_flag,
-                                              &progbar_start_time,
-                                              progbar_val);
-
       if (progbar != NULL) {
         g_snprintf(progbar_status_str, sizeof(progbar_status_str),
                    "%4u of %u packets", progbar_count, cf->count);
@@ -2253,6 +2276,15 @@ cf_change_time_formats(capture_file *cf)
      any columns that show the time in the "command-line-specified"
      format and, if so, update that row. */
   for (fdata = cf->plist, row = -1; fdata != NULL; fdata = fdata->next) {
+    /* Create the progress bar if necessary.
+       We check on every iteration of the loop, so that it takes no
+       longer than the standard time to create it (otherwise, for a
+       large file, we might take considerably longer than that standard
+       time in order to get to the next progress bar step). */
+    if (progbar == NULL)
+      progbar = delayed_create_progress_dlg("Changing", "time display", 
+        &stop_flag, &start_time, prog_val);
+
     /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
        when we update it, we have to run the GTK+ main loop to get it
        to repaint what's pending, and doing so may involve an "ioctl()"
@@ -2266,11 +2298,6 @@ cf_change_time_formats(capture_file *cf)
 
       prog_val = (gfloat) count / cf->count;
 
-      if (progbar == NULL)
-        /* Create the progress bar if necessary */
-        progbar = delayed_create_progress_dlg("Changing", "time display", 
-          &stop_flag, &start_time, prog_val);
-
       if (progbar != NULL) {
         g_snprintf(status_str, sizeof(status_str),
                    "%4u of %u packets", count, cf->count);
@@ -2699,6 +2726,15 @@ find_packet(capture_file *cf,
 
     fdata = start_fd;
     for (;;) {
+      /* Create the progress bar if necessary.
+         We check on every iteration of the loop, so that it takes no
+         longer than the standard time to create it (otherwise, for a
+         large file, we might take considerably longer than that standard
+         time in order to get to the next progress bar step). */
+      if (progbar == NULL)
+         progbar = delayed_create_progress_dlg("Searching", cf->sfilter, 
+           &stop_flag, &start_time, prog_val);
+
       /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
          when we update it, we have to run the GTK+ main loop to get it
          to repaint what's pending, and doing so may involve an "ioctl()"
@@ -2712,11 +2748,6 @@ find_packet(capture_file *cf,
 
         prog_val = (gfloat) count / cf->count;
 
-        /* Create the progress bar if necessary */
-        if (progbar == NULL)
-           progbar = delayed_create_progress_dlg("Searching", cf->sfilter, 
-             &stop_flag, &start_time, prog_val);
-
         if (progbar != NULL) {
           g_snprintf(status_str, sizeof(status_str),
                      "%4u of %u packets", count, cf->count);
index a9865f3dbc4bec8a536fc308ca72af8904d32ec2..ee837faed6a16c29ca4768c6cd7a1dd04efcdcd1 100644 (file)
@@ -633,6 +633,15 @@ packet_list_resize_columns(void) {
     main_window_update();
 
     for (i = 0; i < cfile.cinfo.num_cols; i++) {
+      /* Create the progress bar if necessary.
+         We check on every iteration of the loop, so that it takes no
+         longer than the standard time to create it (otherwise, for a
+         large file, we might take considerably longer than that standard
+         time in order to get to the next progress bar step). */
+      if (progbar == NULL)
+         progbar = delayed_create_progress_dlg("Resizing", "Resize Columns", 
+           &stop_flag, &start_time, prog_val);
+
       if (i >= progbar_nextstep) {
         /* let's not divide by zero. I should never be started
          * with count == 0, so let's assert that
@@ -641,11 +650,6 @@ packet_list_resize_columns(void) {
 
         prog_val = (gfloat) i / cfile.cinfo.num_cols;
 
-        /* Create the progress bar if necessary */
-        if (progbar == NULL)
-           progbar = delayed_create_progress_dlg("Resizing", "Resize Columns", 
-             &stop_flag, &start_time, prog_val);
-
         if (progbar != NULL) {
           g_snprintf(status_str, sizeof(status_str),
                      "%u of %u columns (%s)", i+1, cfile.cinfo.num_cols, cfile.cinfo.col_title[i]);
@@ -660,12 +664,12 @@ packet_list_resize_columns(void) {
         break;
       }
 
-        /* auto resize the current column */
-        eth_clist_set_column_auto_resize(ETH_CLIST(packet_list), i, TRUE);
+      /* auto resize the current column */
+      eth_clist_set_column_auto_resize(ETH_CLIST(packet_list), i, TRUE);
 
-        /* the current column should be resizeable by the user again */
-        /* (will turn off auto resize again) */
-        eth_clist_set_column_resizeable(ETH_CLIST(packet_list), i, TRUE);
+      /* the current column should be resizeable by the user again */
+      /* (will turn off auto resize again) */
+      eth_clist_set_column_resizeable(ETH_CLIST(packet_list), i, TRUE);
     }
 
     /* We're done resizing the columns; destroy the progress bar if it
index f1ece587956323b38d213c62b4d0d8c3d5cefaf6..36a4468d92a7a85d62b58e349b922d5c9559c551 100644 (file)
@@ -1080,6 +1080,17 @@ packet_hex_print_common(GtkTextView *bv, const guint8 *pd, int len, int bstart,
   g_get_current_time(&progbar_start_time);
 
   while (i < len) {
+    /* Create the progress bar if necessary.
+       We check on every iteration of the loop, so that it takes no
+       longer than the standard time to create it (otherwise, for a
+       large packet, we might take considerably longer than that standard
+       time in order to get to the next progress bar step). */
+    if (progbar == NULL)
+      progbar = delayed_create_progress_dlg("Processing", "Packet Details",
+                                            &progbar_stop_flag,
+                                            &progbar_start_time,
+                                            progbar_val);
+
     /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
        when we update it, we have to run the GTK+ main loop to get it
        to repaint what's pending, and doing so may involve an "ioctl()"
@@ -1092,13 +1103,6 @@ packet_hex_print_common(GtkTextView *bv, const guint8 *pd, int len, int bstart,
       g_assert(len > 0);
       progbar_val = (gfloat) i / len;
 
-      if (progbar == NULL)
-        /* Create the progress bar if necessary */
-        progbar = delayed_create_progress_dlg("Processing", "Packet Details",
-                                              &progbar_stop_flag,
-                                              &progbar_start_time,
-                                              progbar_val);
-
       if (progbar != NULL) {
         g_snprintf(progbar_status_str, sizeof(progbar_status_str),
                    "%4u of %u bytes", i, len);
index f1e0d87ef1e387086b738dd665766ba8252be20b..bf67fecf88b3526259adc5f257468baca97f00f8 100644 (file)
@@ -208,6 +208,17 @@ ph_stats_new(void)
        tot_bytes = 0;
 
        for (frame = cfile.plist; frame != NULL; frame = frame->next) {
+               /* Create the progress bar if necessary.
+                  We check on every iteration of the loop, so that
+                  it takes no longer than the standard time to create
+                  it (otherwise, for a large file, we might take
+                  considerably longer than that standard time in order
+                  to get to the next progress bar step). */
+               if (progbar == NULL)
+                       progbar = delayed_create_progress_dlg(
+                           "Computing", "protocol hierarchy statistics", 
+                           &stop_flag, &start_time, prog_val);
+
                /* Update the progress bar, but do it only N_PROGBAR_UPDATES
                   times; when we update it, we have to run the GTK+ main
                   loop to get it to repaint what's pending, and doing so
@@ -222,12 +233,6 @@ ph_stats_new(void)
 
                        prog_val = (gfloat) count / cfile.count;
 
-                       if (progbar == NULL)
-                               /* Create the progress bar if necessary */
-                               progbar = delayed_create_progress_dlg(
-                                   "Computing", "protocol hierarchy statistics", 
-                                   &stop_flag, &start_time, prog_val);
-
                        if (progbar != NULL) {
                                g_snprintf(status_str, sizeof(status_str),
                                        "%4u of %u frames", count, cfile.count);