From efbfbbc96732ba7b0b8f526b07c776908c79533b Mon Sep 17 00:00:00 2001 From: Chris Young Date: Wed, 31 Oct 2012 20:50:22 +0000 Subject: Fix a serious crash that occurs if the underlying window is closed during a hook function invoked from it. --- amiga/gui.c | 12 ++++++++++++ amiga/menu.c | 4 ++-- amiga/menu.h | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'amiga') diff --git a/amiga/gui.c b/amiga/gui.c index 15ac1f553..37f054776 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1927,6 +1927,16 @@ void ami_handle_msg(void) ami_update_throbber(gwin, true); refresh_throbber = FALSE; } + + if(ami_menu_window_close) + { + if(ami_menu_window_close == AMI_MENU_WINDOW_CLOSE_ALL) + ami_quit_netsurf(); + else + ami_close_all_tabs(ami_menu_window_close); + + ami_menu_window_close = NULL; + } } void ami_gui_appicon_remove(struct gui_window_2 *gwin) @@ -2276,6 +2286,8 @@ void ami_quit_netsurf(void) } } while(node = nnode); + + win_destroyed = true; } if(IsMinListEmpty(window_list)) diff --git a/amiga/menu.c b/amiga/menu.c index ab8381a44..b116e1b39 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -676,7 +676,7 @@ static void ami_menu_item_project_closewin(struct Hook *hook, APTR window, struc struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_close_all_tabs(gwin); + ami_menu_window_close = gwin; } static void ami_menu_item_project_print(struct Hook *hook, APTR window, struct IntuiMessage *msg) @@ -736,7 +736,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I static void ami_menu_item_project_quit(struct Hook *hook, APTR window, struct IntuiMessage *msg) { - ami_quit_netsurf(); + ami_menu_window_close = AMI_MENU_WINDOW_CLOSE_ALL; } static void ami_menu_item_edit_cut(struct Hook *hook, APTR window, struct IntuiMessage *msg) diff --git a/amiga/menu.h b/amiga/menu.h index 36c601792..d692320a3 100755 --- a/amiga/menu.h +++ b/amiga/menu.h @@ -63,9 +63,14 @@ #define AMI_MENU_CLEAR FULLMENUNUM(1,5,0) #define AMI_MENU_FIND FULLMENUNUM(2,0,0) +/* A special value for ami_menu_window_close */ +#define AMI_MENU_WINDOW_CLOSE_ALL 1 + struct gui_window; struct gui_window_2; +struct gui_window_2 *ami_menu_window_close; + void ami_free_menulabs(struct gui_window_2 *gwin); struct NewMenu *ami_create_menu(struct gui_window_2 *gwin); void ami_menu_refresh(struct gui_window_2 *gwin); -- cgit v1.2.3