diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-10-27 06:45:37 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-10-27 06:45:37 +0000 |
commit | 0203c65739ed0f814daa513731838e722e6b3cfa (patch) | |
tree | 6f6114bf89e82abb916114bf11f7cb53eeb20f3e /file.c | |
parent | 3e0e3011e28a28944a2ca452921f3162eadc1c5f (diff) |
Check on every iteration of a loop whether to pop up a dialog box,
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.
svn path=/trunk/; revision=16327
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 95 |
1 files changed, 63 insertions, 32 deletions
@@ -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); |