summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2017-01-15 14:55:15 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2017-01-15 14:55:15 (GMT)
commit52f98c9fb2b3dc04412ad25b7c24fa8cf357e78d (patch)
tree744359c561855f16a6fb14c2c189c148e28cc825
parent24fed9d51ccf3e786e59983ae84b4f13e68b0ea4 (diff)
downloadnetsurf-52f98c9fb2b3dc04412ad25b7c24fa8cf357e78d.tar.gz
netsurf-52f98c9fb2b3dc04412ad25b7c24fa8cf357e78d.tar.bz2
Share menuclass object with all browser windows
-rw-r--r--frontends/amiga/gui.c1
-rw-r--r--frontends/amiga/menu.c28
-rw-r--r--frontends/amiga/menu.h1
3 files changed, 26 insertions, 4 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index cb0f2fa..8b389a0 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4603,7 +4603,6 @@ static void gui_window_destroy(struct gui_window *g)
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_BACK]);
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
ami_ctxmenu_release_hook(g->shared->ctxmenu_hook);
- ami_free_menulabs(g->shared->menu_data);
ami_menu_free(g->shared);
free(g->shared->wintitle);
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index cfb3429..8a3ca8d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -99,6 +99,9 @@ struct ami_menu_data {
UWORD flags;
};
+static struct Menu *restrict gui_menu = NULL;
+static int gui_menu_count = 0;
+
static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
static Object *restrict menu_glyph[NSA_GLYPH_MAX];
@@ -591,7 +594,7 @@ static void ami_menu_free_labs(struct ami_menu_data **md, int max)
}
}
-void ami_free_menulabs(struct ami_menu_data **md)
+static void ami_free_menulabs(struct ami_menu_data **md)
{
int i;
@@ -1087,8 +1090,16 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max)
void ami_menu_free(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
- DisposeObject((Object *)gwin->imenu); // if we detach our menu from the window we need to do this manually
+ gui_menu_count--;
+
+ if(gui_menu_count == 0) {
+ ami_free_menulabs(gwin->menu_data);
+ // if we detach our menu from the window we need to do this manually
+ DisposeObject((Object *)gui_menu);
+ gui_menu = NULL;
+ }
} else {
+ ami_free_menulabs(gwin->menu_data);
FreeMenus(gwin->imenu);
}
}
@@ -1105,11 +1116,24 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ if(gui_menu != NULL) {
+ gwin->imenu = gui_menu;
+ gui_menu_count++;
+ return gwin->imenu;
+ }
+ }
+
ami_init_menulabs(gwin->menu_data);
ami_menu_scan(gwin->menu_data);
ami_menu_arexx_scan(gwin->menu_data);
gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ gui_menu = gwin->imenu;
+ gui_menu_count++;
+ }
+
return gwin->imenu;
}
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 35a0ac7..1bb13c4 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -129,7 +129,6 @@ struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
/* specific to browser windows */
-void ami_free_menulabs(struct ami_menu_data **md);
struct Menu *ami_menu_create(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin);
void ami_menu_update_checked(struct gui_window_2 *gwin);