From 45b241906ed3b29ee6bd0e62fe71f1f5a7facba5 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 11 Aug 2004 21:36:30 +0000 Subject: [PATCH] [project @ 2004-08-11 21:36:30 by jmb] Make message handling more robust svn path=/import/netsurf/; revision=1212 --- riscos/gui.c | 4 +--- riscos/print.c | 29 ++++++++++++++++++++++++++--- riscos/print.h | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/riscos/gui.c b/riscos/gui.c index 34672c65f..5cda9a0ee 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1254,10 +1254,8 @@ char *ro_gui_url_file_parse(const char *file_name) void ro_msg_datasave_ack(wimp_message *message) { #ifdef WITH_PRINT - if (print_current_window) { - print_ack(message); + if (print_current_window && print_ack(message)) return; - } #endif switch (gui_current_drag_type) { diff --git a/riscos/print.c b/riscos/print.c index 6dffac88f..97991c1c1 100644 --- a/riscos/print.c +++ b/riscos/print.c @@ -46,6 +46,7 @@ struct gui_window *print_current_window = 0; bool print_active = false; /* static globals */ +static int print_prev_message = 0; static bool print_in_background = false; static float print_scale = 1.0; static int print_num_copies = 1; @@ -82,6 +83,7 @@ void ro_gui_print_open(struct gui_window *g, int x, int y, bool sub_menu, bool k assert(g != NULL); print_current_window = g; + print_prev_message = 0; /* Read Printer Driver name */ e = xpdriver_info(0, 0, 0, 0, &pdName, 0, 0, 0); @@ -275,6 +277,7 @@ void print_send_printsave(struct content *c) warn_user("WimpError", e->errmess); print_cleanup(); } + print_prev_message = m.my_ref; } /** @@ -308,6 +311,9 @@ bool print_send_printtypeknown(wimp_message *m) */ void print_save_bounce(wimp_message *m) { + if (m->my_ref == 0 || m->my_ref != print_prev_message) + return; + /* try to print anyway (we're graphics printing) */ if (print_current_window) { print_document(print_current_window, "printer:"); @@ -323,6 +329,9 @@ void print_save_bounce(wimp_message *m) void print_error(wimp_message *m) { pdriver_message_print_error *p = (pdriver_message_print_error*)&m->data; + if (m->your_ref == 0 || m->your_ref != print_prev_message) + return; + if (m->size == 20) warn_user("PrintErrorRO2", 0); else @@ -338,7 +347,8 @@ void print_error(wimp_message *m) */ void print_type_odd(wimp_message *m) { - if (m->your_ref != 0 && !print_in_background) { + if ((m->your_ref == 0 || m->your_ref == print_prev_message) && + !print_in_background) { /* reply to a previous message (ie printsave) */ if (print_current_window && print_send_printtypeknown(m)) { print_document(print_current_window, "printer:"); @@ -356,18 +366,24 @@ void print_type_odd(wimp_message *m) * Handle message_DATASAVE_ACK for the printing protocol * * \param m the message to handle + * \return true if message successfully handled, false otherwise */ -void print_ack(wimp_message *m) +bool print_ack(wimp_message *m) { int type; os_error *e; + if (m->your_ref == 0 || m->your_ref != print_prev_message) { + LOG(("message ignored")); + return false; + } + /* Read Printer Driver Type */ e = xpdriver_info(&type, 0, 0, 0, 0, 0, 0, 0); if (e) { LOG(("%s", e->errmess)); print_cleanup(); - return; + return true; } type &= 0xFFFF0000; /* we don't care about the version no */ @@ -414,7 +430,10 @@ void print_ack(wimp_message *m) 0, 0, 0, 0, 0); print_cleanup(); } + print_prev_message = m->my_ref; } + + return true; } /** @@ -424,6 +443,9 @@ void print_ack(wimp_message *m) */ void print_dataload_bounce(wimp_message *m) { + if (m->your_ref == 0 || m->your_ref != print_prev_message) + return; + xosfile_delete(m->data.data_xfer.file_name, 0, 0, 0, 0, 0); print_cleanup(); } @@ -437,6 +459,7 @@ void print_cleanup(void) print_current_window->option.background_images = print_bg_images; print_current_window = 0; + print_prev_message = 0; print_max_sheets = -1; xwimp_create_menu((wimp_menu *)-1, 0, 0); ro_gui_dialog_close(dialog_print); diff --git a/riscos/print.h b/riscos/print.h index c499167f7..9a338c7a6 100644 --- a/riscos/print.h +++ b/riscos/print.h @@ -15,7 +15,7 @@ extern struct gui_window *print_current_window; void print_save_bounce(wimp_message *m); void print_error(wimp_message *m); void print_type_odd(wimp_message *m); -void print_ack(wimp_message *m); +bool print_ack(wimp_message *m); void print_dataload_bounce(wimp_message *m); void print_cleanup(void);