aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-02-29 18:52:52 -0800
committerGuy Harris <guy@alum.mit.edu>2016-03-01 02:53:44 +0000
commitc73cf3cd00c1fb144e67ef79ea55be41993b79be (patch)
tree19a5343fab0b5abeb2832417f20cd7af78642dae
parentc0b29fcddd6eb9c7956ff63836a71a1d90169daa (diff)
Don't show a progress bar when previewing for the Qt print dialog.
We don't do much work to do that - we don't print anything before the first selected page, and once we're finished generating that page, we terminate the printing process - so it shouldn't need a progress bar. (If it needs a progress bar, We Have A Problem, as that slows down the drawing of the dialog box.) This should prevent the problem seen in bug 12040. Bug: 12040 Change-Id: I129191e06fff3e1eb59a9631c7395b9e7f650809 Reviewed-on: https://code.wireshark.org/review/14255 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--file.c28
-rw-r--r--file.h4
-rw-r--r--ui/gtk/print_dlg.c2
-rw-r--r--ui/qt/export_dissection_dialog.cpp2
-rw-r--r--ui/qt/print_dialog.cpp14
-rw-r--r--ui/win32/file_dlg_win32.c4
6 files changed, 30 insertions, 24 deletions
diff --git a/file.c b/file.c
index 39fbd6dc16..a0c21b2ddb 100644
--- a/file.c
+++ b/file.c
@@ -1977,7 +1977,8 @@ process_specified_records(capture_file *cf, packet_range_t *range,
const char *string1, const char *string2, gboolean terminate_is_stop,
gboolean (*callback)(capture_file *, frame_data *,
struct wtap_pkthdr *, const guint8 *, void *),
- void *callback_args)
+ void *callback_args,
+ gboolean show_progress_bar)
{
guint32 framenum;
frame_data *fdata;
@@ -2023,7 +2024,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
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)
+ if (show_progress_bar && progbar == NULL)
progbar = delayed_create_progress_dlg(cf->window, string1, string2,
terminate_is_stop,
&cf->stop_flag,
@@ -2158,7 +2159,7 @@ cf_retap_packets(capture_file *cf)
ret = process_specified_records(cf, &range, "Recalculating statistics on",
"all packets", TRUE, retap_packet,
- &callback_args);
+ &callback_args, TRUE);
epan_dissect_cleanup(&callback_args.edt);
@@ -2347,7 +2348,8 @@ fail:
}
cf_print_status_t
-cf_print_packets(capture_file *cf, print_args_t *print_args)
+cf_print_packets(capture_file *cf, print_args_t *print_args,
+ gboolean show_progress_bar)
{
print_callback_args_t callback_args;
gint data_width;
@@ -2475,7 +2477,7 @@ cf_print_packets(capture_file *cf, print_args_t *print_args)
told to print. */
ret = process_specified_records(cf, &print_args->range, "Printing",
"selected packets", TRUE, print_packet,
- &callback_args);
+ &callback_args, show_progress_bar);
epan_dissect_cleanup(&callback_args.edt);
g_free(callback_args.header_line_buf);
g_free(callback_args.line_buf);
@@ -2566,7 +2568,7 @@ cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
told to print. */
ret = process_specified_records(cf, &print_args->range, "Writing PDML",
"selected packets", TRUE,
- write_pdml_packet, &callback_args);
+ write_pdml_packet, &callback_args, TRUE);
epan_dissect_cleanup(&callback_args.edt);
@@ -2648,7 +2650,7 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
told to print. */
ret = process_specified_records(cf, &print_args->range, "Writing PSML",
"selected packets", TRUE,
- write_psml_packet, &callback_args);
+ write_psml_packet, &callback_args, TRUE);
epan_dissect_cleanup(&callback_args.edt);
@@ -2728,7 +2730,7 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args)
told to print. */
ret = process_specified_records(cf, &print_args->range, "Writing CSV",
"selected packets", TRUE,
- write_csv_packet, &callback_args);
+ write_csv_packet, &callback_args, TRUE);
epan_dissect_cleanup(&callback_args.edt);
@@ -2791,9 +2793,9 @@ cf_write_carrays_packets(capture_file *cf, print_args_t *print_args)
/* Iterate through the list of packets, printing the packets we were
told to print. */
ret = process_specified_records(cf, &print_args->range,
- "Writing C Arrays",
- "selected packets", TRUE,
- carrays_write_packet, &callback_args);
+ "Writing C Arrays",
+ "selected packets", TRUE,
+ carrays_write_packet, &callback_args, TRUE);
epan_dissect_cleanup(&callback_args.edt);
@@ -4525,7 +4527,7 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
callback_args.fname = fname;
callback_args.file_type = save_format;
switch (process_specified_records(cf, NULL, "Saving", "packets",
- TRUE, save_record, &callback_args)) {
+ TRUE, save_record, &callback_args, TRUE)) {
case PSP_FINISHED:
/* Completed successfully. */
@@ -4763,7 +4765,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
callback_args.fname = fname;
callback_args.file_type = save_format;
switch (process_specified_records(cf, range, "Writing", "specified records",
- TRUE, save_record, &callback_args)) {
+ TRUE, save_record, &callback_args, TRUE)) {
case PSP_FINISHED:
/* Completed successfully. */
diff --git a/file.h b/file.h
index 2403e24707..a52f9a454e 100644
--- a/file.h
+++ b/file.h
@@ -420,9 +420,11 @@ void cf_timestamp_auto_precision(capture_file *cf);
*
* @param cf the capture file
* @param print_args the arguments what and how to print
+ * @param show_progress_bar TRUE if a progress bar is to be shown
* @return one of cf_print_status_t
*/
-cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args);
+cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args,
+ gboolean show_progress_bar);
/**
* Print (export) the capture file into PDML format.
diff --git a/ui/gtk/print_dlg.c b/ui/gtk/print_dlg.c
index d3f9b5deb7..262e953695 100644
--- a/ui/gtk/print_dlg.c
+++ b/ui/gtk/print_dlg.c
@@ -1109,7 +1109,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
g_assert_not_reached();
return;
}
- status = cf_print_packets(&cfile, args);
+ status = cf_print_packets(&cfile, args, TRUE);
}
switch (status) {
diff --git a/ui/qt/export_dissection_dialog.cpp b/ui/qt/export_dissection_dialog.cpp
index afd84243cc..53f6f869e1 100644
--- a/ui/qt/export_dissection_dialog.cpp
+++ b/ui/qt/export_dissection_dialog.cpp
@@ -168,7 +168,7 @@ int ExportDissectionDialog::exec()
open_failure_alert_box(print_args_.file, errno, TRUE);
return QDialog::Rejected;
}
- status = cf_print_packets(cap_file_, &print_args_);
+ status = cf_print_packets(cap_file_, &print_args_, TRUE);
break;
case export_type_csv: /* CSV */
status = cf_write_csv_packets(cap_file_, &print_args_);
diff --git a/ui/qt/print_dialog.cpp b/ui/qt/print_dialog.cpp
index 58f4cb0bba..07979b5306 100644
--- a/ui/qt/print_dialog.cpp
+++ b/ui/qt/print_dialog.cpp
@@ -145,6 +145,8 @@ gboolean PrintDialog::printHeader()
if (page_pos_ > page_top) {
if (in_preview_) {
+ // When generating a preview, only generate the first page;
+ // if we're past the first page, stop the printing process.
return FALSE;
}
// Second and subsequent pages only
@@ -178,6 +180,8 @@ gboolean PrintDialog::printLine(int indent, const char *line)
if (cur_printer_->pageRect().height() < page_pos_ + out_rect.height()) {
if (in_preview_) {
+ // When generating a preview, only generate the first page;
+ // if we're past the first page, stop the printing process.
return FALSE;
}
if (*line == '\0') { // Separator
@@ -257,12 +261,10 @@ void PrintDialog::printPackets(QPrinter *printer, bool in_preview)
QMessageBox::Ok);
close();
}
- // cf_print_packets updates the progress bar which in turn calls
- // WiresharkApplication::processEvents(), which can make the preview trip
- // over itself.
- preview_->setUpdatesEnabled(false);
- cf_print_packets(cap_file_, &print_args_);
- preview_->setUpdatesEnabled(true);
+ // Don't show a progress bar if we're previewing; if it takes a
+ // significant amount of time to generate a preview of the first
+ // page, We Have A Real Problem
+ cf_print_packets(cap_file_, &print_args_, in_preview ? FALSE : TRUE);
cur_printer_ = NULL;
cur_painter_ = NULL;
painter.end();
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index b7630dfd14..15eca21a30 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -697,7 +697,7 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
g_free( (void *) ofn);
return;
}
- status = cf_print_packets(cf, &print_args);
+ status = cf_print_packets(cf, &print_args, TRUE);
break;
case export_type_ps: /* PostScript (r) */
print_args.stream = print_stream_ps_new(TRUE, print_args.file);
@@ -706,7 +706,7 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
g_free( (void *) ofn);
return;
}
- status = cf_print_packets(cf, &print_args);
+ status = cf_print_packets(cf, &print_args, TRUE);
break;
case export_type_csv: /* CSV */
status = cf_write_csv_packets(cf, &print_args);