From 9e814fd0f0f03584debb43b6d8acf144bd8675a2 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 15 Jan 2017 20:01:49 +0000 Subject: minor menu fixes --- frontends/amiga/gui.c | 3 +-- frontends/amiga/gui_menu.c | 3 +++ frontends/amiga/menu.c | 14 ++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'frontends/amiga') diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index c6ca886f7..b2a489e72 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -3335,8 +3335,7 @@ void ami_gui_hotlist_update_all(void) nnode=(struct nsObject *)GetSucc((struct Node *)node); gwin = node->objstruct; - if(node->Type == AMINS_WINDOW) - { + if(node->Type == AMINS_WINDOW) { ami_gui_hotlist_toolbar_update(gwin); } } while((node = nnode)); diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c index c453c64d8..6b9b2075d 100644 --- a/frontends/amiga/gui_menu.c +++ b/frontends/amiga/gui_menu.c @@ -1084,6 +1084,7 @@ static void ami_free_menulabs(struct ami_menu_data **md) md[i]->menukey = NULL; md[i]->menutype = 0; free(md[i]); + md[i] = NULL; } } @@ -1093,6 +1094,8 @@ void ami_gui_menu_free(struct gui_window_2 *gwin) #ifdef __amigaos4__ gui_menu_count--; + SetAttrs(gwin->objects[OID_MAIN], WINDOW_MenuStrip, NULL, TAG_DONE); + if(gui_menu_count == 0) { ami_free_menulabs(gui_menu_data); // if we detach our menu from the window we need to do this manually diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c index cfbbd8deb..91acce72d 100644 --- a/frontends/amiga/menu.c +++ b/frontends/amiga/menu.c @@ -100,6 +100,7 @@ void ami_menu_free_lab_item(struct ami_menu_data **md, int i) md[i]->menukey = NULL; md[i]->menutype = 0; free(md[i]); + md[i] = NULL; } static void ami_menu_free_labs(struct ami_menu_data **md, int max) @@ -115,8 +116,6 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type, const char *restrict label, const char *restrict key, const char *restrict icon, void *restrict func, void *restrict hookdata, UWORD flags) { - char menu_icon[1024]; - md[num] = calloc(1, sizeof(struct ami_menu_data)); md[num]->menutype = type; md[num]->flags = flags; @@ -127,11 +126,7 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type, md[num]->menulab = NM_BARLABEL; icon = NULL; } else { /* horrid non-generic stuff */ - if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) { - utf8_from_local_encoding(label, - (strlen(label) < NSA_MAX_HOTLIST_MENU_LEN) ? strlen(label) : NSA_MAX_HOTLIST_MENU_LEN, - (char **)&md[num]->menulab); - } else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) { + if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) { md[num]->menulab = strdup(label); } else { md[num]->menulab = ami_utf8_easy(messages_get(label)); @@ -144,6 +139,8 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type, if(hookdata) md[num]->menu_hook.h_Data = hookdata; #ifdef __amigaos4__ + char menu_icon[1024]; + if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) { if(icon) { if(ami_locate_resource(menu_icon, icon) == true) { @@ -265,6 +262,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat TAG_DONE); } + LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent); IDoMethod(menu_parent, OM_ADDMEMBER, menu_item); continue; } else if (md[j]->menutype > level) { @@ -452,7 +450,7 @@ void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_ite /* remove all children */ while((obj = (Object *)IDoMethod(menu_item_obj, MM_NEXTCHILD, 0, NULL)) != NULL) { IDoMethod(menu_item_obj, OM_REMMEMBER, obj); - /* do we need to disposeobject? */ + DisposeObject(obj); } /* free associated data */ -- cgit v1.2.3