From fea40a0a78a70a29573bbdc940ea6f9ccdb6093b Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 17 Aug 2015 18:15:29 +0100 Subject: Restrict all menu icon code to OS4+gadtools53.7 This avoids requests for TBimages: on OS3 --- amiga/font_scan.c | 3 ++- amiga/menu.c | 68 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/amiga/font_scan.c b/amiga/font_scan.c index 4f4b774b1..b65798d6e 100644 --- a/amiga/font_scan.c +++ b/amiga/font_scan.c @@ -215,7 +215,7 @@ static void ami_font_scan_gui_close(struct ami_font_scan_window *fsw) static ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray) { struct OutlineFont *ofont; - struct MinList *widthlist; + struct MinList *widthlist = NULL; struct GlyphWidthEntry *gwnode; ULONG foundglyphs = 0; lwc_error lerror; @@ -482,6 +482,7 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save, found = ami_font_scan_load(filename, glypharray); if(found == 0) { + LOG("Creating new font glyph cache"); if((list = NewObjList())) { /* add preferred fonts list */ diff --git a/amiga/menu.c b/amiga/menu.c index 21c12b925..c59959660 100644 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -566,14 +566,18 @@ static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type, if(func) gwin->menu_hook[num].h_Entry = (HOOKFUNC)func; if(hookdata) gwin->menu_hook[num].h_Data = hookdata; - if(icon) { - if(ami_locate_resource(menu_icon, icon) == true) { - gwin->menuicon[num] = (char *)strdup(menu_icon); - } else { - /* If the requested icon can't be found, put blank space in instead */ - gwin->menuicon[num] = (char *)strdup(NSA_SPACE); +#ifdef __amigaos4__ + if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) { + if(icon) { + if(ami_locate_resource(menu_icon, icon) == true) { + gwin->menuicon[num] = (char *)strdup(menu_icon); + } else { + /* If the requested icon can't be found, put blank space in instead */ + gwin->menuicon[num] = (char *)strdup(NSA_SPACE); + } } } +#endif } static void ami_init_menulabs(struct gui_window_2 *gwin) @@ -728,38 +732,42 @@ void ami_menu_refresh(struct gui_window_2 *gwin) static void ami_menu_load_glyphs(struct DrawInfo *dri) { #ifdef __amigaos4__ - for(int i = 0; i < NSA_GLYPH_MAX; i++) - menu_glyph[i] = NULL; - - menu_glyph[NSA_GLYPH_SUBMENU] = NewObject(NULL, "sysiclass", - SYSIA_Which, MENUSUB, - SYSIA_DrawInfo, dri, - TAG_DONE); - menu_glyph[NSA_GLYPH_AMIGAKEY] = NewObject(NULL, "sysiclass", - SYSIA_Which, AMIGAKEY, - SYSIA_DrawInfo, dri, - TAG_DONE); - GetAttr(IA_Width, menu_glyph[NSA_GLYPH_SUBMENU], - (ULONG *)&menu_glyph_width[NSA_GLYPH_SUBMENU]); - GetAttr(IA_Width, menu_glyph[NSA_GLYPH_AMIGAKEY], - (ULONG *)&menu_glyph_width[NSA_GLYPH_AMIGAKEY]); + if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) { + for(int i = 0; i < NSA_GLYPH_MAX; i++) + menu_glyph[i] = NULL; + + menu_glyph[NSA_GLYPH_SUBMENU] = NewObject(NULL, "sysiclass", + SYSIA_Which, MENUSUB, + SYSIA_DrawInfo, dri, + TAG_DONE); + menu_glyph[NSA_GLYPH_AMIGAKEY] = NewObject(NULL, "sysiclass", + SYSIA_Which, AMIGAKEY, + SYSIA_DrawInfo, dri, + TAG_DONE); + GetAttr(IA_Width, menu_glyph[NSA_GLYPH_SUBMENU], + (ULONG *)&menu_glyph_width[NSA_GLYPH_SUBMENU]); + GetAttr(IA_Width, menu_glyph[NSA_GLYPH_AMIGAKEY], + (ULONG *)&menu_glyph_width[NSA_GLYPH_AMIGAKEY]); - menu_glyphs_loaded = true; + menu_glyphs_loaded = true; + } #endif } void ami_menu_free_glyphs(void) { #ifdef __amigaos4__ - int i; - if(menu_glyphs_loaded == false) return; + if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 7)) { + int i; + if(menu_glyphs_loaded == false) return; + + for(i = 0; i < NSA_GLYPH_MAX; i++) { + if(menu_glyph[i]) DisposeObject(menu_glyph[i]); + menu_glyph[i] = NULL; + }; - for(i = 0; i < NSA_GLYPH_MAX; i++) { - if(menu_glyph[i]) DisposeObject(menu_glyph[i]); - menu_glyph[i] = NULL; - }; - - menu_glyphs_loaded = false; + menu_glyphs_loaded = false; + } #endif } -- cgit v1.2.3