From e5129294c05fcca8bb44cb915b5bcff9857d9ae0 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Mon, 26 Mar 2007 12:28:19 +0000 Subject: [PATCH] Call close functions when automatically closing child windows and when automatically handlign Cancel buttons. svn path=/trunk/netsurf/; revision=3225 --- riscos/dialog.c | 6 +++--- riscos/wimp_event.c | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/riscos/dialog.c b/riscos/dialog.c index 5352f2a68..c0d224d69 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -365,9 +365,7 @@ void ro_gui_dialog_close(wimp_w close) } /* Close any child windows */ - for (i = 0; i < MAX_PERSISTENT; i++) - if (persistent_dialog[i].parent == close) - ro_gui_dialog_close(persistent_dialog[i].dialog); + ro_gui_dialog_close_persistent(close); /* Give the caret back to the parent window. This code relies on the fact that only tree windows and browser windows open @@ -642,6 +640,8 @@ void ro_gui_dialog_close_persistent(wimp_w parent) { if (persistent_dialog[i].parent == parent && persistent_dialog[i].dialog != NULL) { ro_gui_dialog_close(persistent_dialog[i].dialog); + ro_gui_wimp_event_close_window(persistent_dialog[i].dialog); + persistent_dialog[i].parent = NULL; persistent_dialog[i].dialog = NULL; } } diff --git a/riscos/wimp_event.c b/riscos/wimp_event.c index 199010a7a..b8690f5c0 100644 --- a/riscos/wimp_event.c +++ b/riscos/wimp_event.c @@ -227,6 +227,7 @@ void ro_gui_wimp_event_finalise(wimp_w w) { struct event_window *window; struct icon_event *event; + LOG(("Removing all events for window 0x%x", (unsigned int)w)); window = ro_gui_wimp_event_remove_window(w); if (!window) return; @@ -544,6 +545,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) { case EVENT_CANCEL: if (pointer->buttons & wimp_CLICK_SELECT) { ro_gui_dialog_close(pointer->w); + ro_gui_wimp_event_close_window(pointer->w); ro_gui_menu_closed(true); } else { ro_gui_wimp_event_restore(pointer->w); @@ -622,6 +624,7 @@ void ro_gui_wimp_event_ok_click(struct event_window *window, wimp_mouse_state st if (state & wimp_CLICK_SELECT) { ro_gui_dialog_close(window->w); + ro_gui_wimp_event_close_window(window->w); ro_gui_menu_closed(true); } else { ro_gui_wimp_event_memorise(window->w); @@ -812,6 +815,7 @@ bool ro_gui_wimp_event_keypress(wimp_key *key) { wimp_WINDOW_CLOSE_ICON)) return false; ro_gui_dialog_close(key->w); + ro_gui_wimp_event_close_window(key->w); ro_gui_menu_closed(true); return true; /* Return performs the OK action */ @@ -851,6 +855,7 @@ bool ro_gui_wimp_event_open_window(wimp_open *open) { bool ro_gui_wimp_event_close_window(wimp_w w) { struct event_window *window; + LOG(("Close event received for window 0x%x", (unsigned int)w)); window = ro_gui_wimp_event_find_window(w); if ((window) && (window->close_window)) { window->close_window(w); @@ -1122,10 +1127,12 @@ struct event_window *ro_gui_wimp_event_get_window(wimp_w w) { struct event_window *window; int h; + assert((int)w != 0); window = ro_gui_wimp_event_find_window(w); if (window) return window; + LOG(("Creating structure for window 0x%x", (unsigned int)w)); window = calloc(1, sizeof(struct event_window)); if (!window) return NULL;