#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 28 Feb 2017 13:45:47 +0100
changeset 21594 acb127ad113c
parent 21593 bdcb1244b97d
child 21595 10b14f01369b
#FEATURE by cg class: OSXOperatingSystem changed: #getNSApp
OSXOperatingSystem.st
--- a/OSXOperatingSystem.st	Tue Feb 28 12:43:29 2017 +0100
+++ b/OSXOperatingSystem.st	Tue Feb 28 13:45:47 2017 +0100
@@ -364,21 +364,41 @@
     Class AppDelClass = NULL;
     id NSApp = NULL;
 
+    id poolClass = objc_getClass("NSAutoreleasePool");
+    if (poolClass == NULL) {
+        fprintf(stderr, "OSX: Unable to get NSAutoreleasePool\n");
+        RETURN(false);
+    }
+    id pool = objc_msgSend(poolClass, sel_registerName("alloc"));
+    if (pool == NULL) {
+        fprintf(stderr, "OSX: Unable to create NSAutoreleasePool\n");
+        RETURN(false);
+    }
+    objc_msgSend(pool, sel_registerName("init"));
+
+#if 0 /* not needed */
     AppDelClass = objc_allocateClassPair((Class)objc_getClass("NSObject"), "AppDelegate", 0);
     class_addMethod(AppDelClass, sel_getUid("applicationDidFinishLaunching:"), (IMP)AppDel_didFinishLaunching, "i@:@");
     objc_registerClassPair(AppDelClass);
+#endif
 
     NSApp = objc_msgSend((id)objc_getClass("NSApplication"), sel_getUid("sharedApplication"));
     if (NSApp == NULL) {
-	fprintf(stderr,"OSX: Failed to initialize NSApplication.\n");
-	RETURN(false);
+        fprintf(stderr,"OSX: Failed to initialize NSApplication\n");
+        RETURN(false);
     }
     @global(NSApp) = __MKEXTERNALADDRESS(NSApp);
 
-    id appDelObj = objc_msgSend((id)objc_getClass("AppDelegate"), sel_getUid("alloc"));
-    appDelObj = objc_msgSend(appDelObj, sel_getUid("init"));
+    id req = objc_msgSend(NSApp,sel_getUid("requestUserAttention:"),0);
+    objc_msgSend(NSApp,sel_getUid("cancelUserAttentionRequest:"),req);
 
-    objc_msgSend(NSApp, sel_getUid("setDelegate:"), appDelObj);
+#if 0 /* not needed */
+    id appDelInst = objc_msgSend((id)objc_getClass("AppDelegate"), sel_getUid("alloc"));
+    objc_msgSend(appDelInst, sel_getUid("init"));
+    objc_msgSend(NSApp, sel_getUid("setDelegate:"), appDelInst);
+#endif
+
+    objc_msgSend(pool, sel_registerName("release"));
     RETURN(true);
 #endif // NO_COCOA
 %}.
@@ -388,7 +408,7 @@
      self getNSApp
     "
 
-    "Modified (comment): / 28-02-2017 / 01:35:31 / cg"
+    "Modified: / 28-02-2017 / 13:45:39 / cg"
 !
 
 receiveNextEvent