From d132de18a6bc066d2c25ddcb9527918f70fa4c39 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 15 Aug 2014 12:56:33 -0400 Subject: [PATCH] I HAVE DEFEATED APPKIT. --- redo/uitask_darwin.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/redo/uitask_darwin.m b/redo/uitask_darwin.m index e45e09c..d802911 100644 --- a/redo/uitask_darwin.m +++ b/redo/uitask_darwin.m @@ -4,6 +4,8 @@ #import "_cgo_export.h" #import +#define toNSWindow(x) ((NSWindow *) (x)) + static Class areaClass; @interface goApplication : NSApplication @@ -41,6 +43,15 @@ static Class areaClass; [super sendEvent:e]; } +// ok AppKit, wanna play hardball? let's play hardball. +// because I can neither break out of the special version of the NSModalPanelRunLoopMode that the regular terminate: puts us in nor avoid the exit(0); call included, I'm taking control +// note that this is called AFTER applicationShouldTerminate: +- (void)terminate:(id)sender +{ + // DO ABSOLUTELY NOTHING + // the magic is [NSApp run] will just... stop. +} + @end @interface appDelegateClass : NSObject @@ -64,9 +75,8 @@ static Class areaClass; return NSTerminateCancel; } // all windows closed; stop gracefully for Go - uistop(); - // TODO can't use NSTerminateLater here as the run loop is different (???) - return NSTerminateCancel; + // note that this is designed for our special terminate: above + return NSTerminateNow; } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app @@ -97,6 +107,7 @@ void uiinit(char **errmsg) void uimsgloop(void) { [NSApp run]; +// NSLog(@"you shouldn't see this under normal circumstances, but screw the rules, I have SUBCLASSING"); } // don't use [NSApp terminate:]; that quits the program