Implemented menu finalization on OS X.
This commit is contained in:
parent
9e6678b635
commit
82312861e9
|
@ -3,7 +3,7 @@
|
|||
|
||||
// general TODO: release Objective-C objects in dealloc since we can't use ARC
|
||||
|
||||
// TODO menu finalization
|
||||
static BOOL menusFinalized = NO;
|
||||
|
||||
struct menu {
|
||||
uiMenu m;
|
||||
|
@ -241,6 +241,9 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
|
|||
{
|
||||
struct menuItem *item;
|
||||
|
||||
if (menusFinalized)
|
||||
complain("attempt to create a new menu item after menus have been finalized");
|
||||
|
||||
item = uiNew(struct menuItem);
|
||||
|
||||
item->type = type;
|
||||
|
@ -317,6 +320,9 @@ uiMenu *uiNewMenu(const char *name)
|
|||
{
|
||||
struct menu *m;
|
||||
|
||||
if (menusFinalized)
|
||||
complain("attempt to create a new menu after menus have been finalized");
|
||||
|
||||
m = uiNew(struct menu);
|
||||
|
||||
m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)];
|
||||
|
@ -336,3 +342,8 @@ uiMenu *uiNewMenu(const char *name)
|
|||
|
||||
return uiMenu(m);
|
||||
}
|
||||
|
||||
void finalizeMenus(void)
|
||||
{
|
||||
menusFinalized = YES;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||
- (NSMenu *)makeMenubar;
|
||||
@end
|
||||
extern void finalizeMenus(void);
|
||||
|
||||
// init.m
|
||||
@interface appDelegate : NSObject <NSApplicationDelegate>
|
||||
|
|
|
@ -182,6 +182,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
struct window *w;
|
||||
NSView *binView;
|
||||
|
||||
finalizeMenus();
|
||||
|
||||
w = uiNew(struct window);
|
||||
|
||||
w->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
|
||||
|
|
Loading…
Reference in New Issue