From 53bf136f01143c17644f9fd86c632a2f24155d2c Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 12 Sep 2008 06:13:47 +0000 Subject: [PATCH] menu item cleanup fixes git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2542 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/menus.cpp | 25 +++++++++++++++---------- source/src/protos.h | 4 +--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/source/src/menus.cpp b/source/src/menus.cpp index f0a7a9b8..3ed9b7a9 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -133,17 +133,11 @@ color mitem::whitepulse(1.0f, 1.0f, 1.0f); // text item -struct mitemtext : mitem +struct mitemmanual : mitem { char *text, *action, *hoveraction; - mitemtext(gmenu *parent, char *text, char *action, char *hoveraction, color *bgcolor) : mitem(parent, bgcolor), text(text), action(action), hoveraction(hoveraction) {} - virtual ~mitemtext() - { - DELETEA(text); - DELETEA(action); - DELETEA(hoveraction); - } + mitemmanual(gmenu *parent, char *text, char *action, char *hoveraction, color *bgcolor) : mitem(parent, bgcolor), text(text), action(action), hoveraction(hoveraction) {} virtual int width() { return text_width(text); } @@ -171,6 +165,17 @@ struct mitemtext : mitem } }; +struct mitemtext : mitemmanual +{ + mitemtext(gmenu *parent, char *text, char *action, char *hoveraction, color *bgcolor) : mitemmanual(parent, text, action, hoveraction, bgcolor) {} + virtual ~mitemtext() + { + DELETEA(text); + DELETEA(action); + DELETEA(hoveraction); + } +}; + // text input item struct mitemtextinput : mitemtext @@ -475,7 +480,7 @@ void menumanual(void *menu, int n, char *text, char *action, color *bgcolor) { gmenu &m = *(gmenu *)menu; if(!n) m.items.deletecontentsp(); - m.items.add(new mitemtext(&m, text, action, NULL, bgcolor)); + m.items.add(new mitemmanual(&m, text, action, NULL, bgcolor)); } void menuheader(void *menu, char *header, char *footer) @@ -715,7 +720,7 @@ void gmenu::init() { char *f = files[i]; if(!f || !f[0]) continue; - items.add(new mitemtext(this, f, dirlist->action, NULL, NULL)); + items.add(new mitemtext(this, f, newstring(dirlist->action), NULL, NULL)); } } loopv(items) items[i]->init(); diff --git a/source/src/protos.h b/source/src/protos.h index 5e73dd6a..2286e435 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -104,7 +104,7 @@ struct mitem color *bgcolor; mitem(gmenu *parent, color *bgcolor) : parent(parent), bgcolor(bgcolor) {} - virtual ~mitem() { delete bgcolor; } + virtual ~mitem() {} virtual void render(int x, int y, int w); virtual int width() = 0; @@ -147,8 +147,6 @@ struct gmenu { DELETEA(name); DELETEA(title); - DELETEA(header); - DELETEA(footer); DELETEA(mdl); DELETEP(dirlist); DELETEA(initaction);