changeset 5269:3d5e83373a39

7132692: [macosx] Class com.apple.eawt not functioning Summary: Postpone setting the application delegate until the app is fully initialized Reviewed-by: art
author anthony
date Tue, 27 Mar 2012 15:53:29 +0400
parents 4008c98ad48a
children 74a1284ca75a
files src/macosx/native/sun/awt/awt.m
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/awt.m	Tue Mar 27 15:49:17 2012 +0400
+++ b/src/macosx/native/sun/awt/awt.m	Tue Mar 27 15:53:29 2012 +0400
@@ -306,6 +306,18 @@
         // AWT gets here AFTER +[AWTStarter appKitIsRunning:] is called.
         if (verbose) AWT_DEBUG_LOG(@"got out of the AppKit startup mutex");
     }
+
+    // Don't set the delegate until the NSApplication has been created and
+    // its finishLaunching has initialized it.
+    //  ApplicationDelegate is the support code for com.apple.eawt.
+    void (^setDelegateBlock)() = ^(){
+        OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]);
+    };
+    if (onMainThread) {
+        setDelegateBlock();
+    } else {
+        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:setDelegateBlock];
+    }
 }
 
 - (void)starter:(NSArray*)args {
@@ -340,10 +352,6 @@
     //  AppKit Application.
     NSApplication *app = [NSApplicationAWT sharedApplication];
 
-    // Don't set the delegate until the NSApplication has been created.
-    //  ApplicationDelegate is the support code for com.apple.eawt.
-    OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]);
-
     // AWT gets to this point BEFORE NSApplicationDidFinishLaunchingNotification is sent.
     if (![app isRunning]) {
         if (verbose) AWT_DEBUG_LOG(@"+[AWTStarter startAWT]: ![app isRunning]");