Fix a serious crash that occurs if the underlying window is closed during a hook function invoked from it.

This commit is contained in:
Chris Young 2012-10-31 20:50:22 +00:00
parent 116cd6aa43
commit efbfbbc967
3 changed files with 19 additions and 2 deletions

View File

@ -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))

View File

@ -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)

View File

@ -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);