Implemented uninitMenus() on Windows.

This commit is contained in:
Pietro Gagliardi 2015-05-08 14:23:22 -04:00
parent d43c8b5584
commit 04923399fe
3 changed files with 29 additions and 1 deletions

View File

@ -107,7 +107,7 @@ const char *uiInit(uiInitOptions *o)
void uiUninit(void)
{
// TODO free menus
uninitMenus();
// TODO delete hollow brush
// TODO uninit container
// TODO delete message font

View File

@ -351,3 +351,30 @@ void freeMenubar(HMENU menubar)
}
// no need to worry about destroying any menus; destruction of the window they're in will do it for us
}
void uninitMenus(void)
{
struct menu *m;
struct menuItem *item;
uintmax_t i, j;
for (i = 0; i < len; i++) {
m = menus[i];
uiFree(m->name);
for (j = 0; j < m->len; j++) {
item = m->items[j];
if (item->len != 0)
complain("menu item %p (%ws) still has uiWindows attached; did you forget to free some?", item, item->name);
if (item->name != NULL)
uiFree(item->name);
if (item->hmenus != NULL)
uiFree(item->hmenus);
uiFree(item);
}
if (m->items != NULL)
uiFree(m->items);
uiFree(m);
}
if (menus != NULL)
uiFree(menus);
}

View File

@ -82,6 +82,7 @@ extern HMENU makeMenubar(void);
extern const uiMenuItem *menuIDToItem(UINT_PTR);
extern void runMenuEvent(WORD, uiWindow *);
extern void freeMenubar(HMENU);
extern void uninitMenus(void);
// alloc.c
extern int initAlloc(void);