Implemented uninitMenus() on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2015-05-08 20:31:19 -04:00
parent 2ec8fb8589
commit f47c8172e1
3 changed files with 26 additions and 1 deletions

View File

@ -65,7 +65,7 @@ const char *uiInit(uiInitOptions *o)
void uiUninit(void) void uiUninit(void)
{ {
// TODO free menus uninitMenus();
// TODO free application delegate // TODO free application delegate
uninitAlloc(); uninitAlloc();
} }

View File

@ -347,3 +347,27 @@ void finalizeMenus(void)
{ {
menusFinalized = YES; menusFinalized = YES;
} }
void uninitMenus(void)
{
if (menus == NULL)
return;
[menus enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSValue *v;
struct menu *m;
v = (NSValue *) obj;
m = (struct menu *) [v pointerValue];
[m->items enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSValue *v;
struct menuItem *mi;
v = (NSValue *) obj;
mi = (struct menuItem *) [v pointerValue];
uiFree(mi);
}];
[m->items release];
uiFree(m);
}];
[menus release];
}

View File

@ -30,6 +30,7 @@
- (NSMenu *)makeMenubar; - (NSMenu *)makeMenubar;
@end @end
extern void finalizeMenus(void); extern void finalizeMenus(void);
extern void uninitMenus(void);
// init.m // init.m
@interface appDelegate : NSObject <NSApplicationDelegate> @interface appDelegate : NSObject <NSApplicationDelegate>