diff --git a/src/macosx/native/sun/awt/LWCToolkit.m b/src/macosx/native/sun/awt/LWCToolkit.m index f56f58770937ddc4264984100fa150fb926a6156..08f0bb7a9d8063fc2256b585410aa091d497f7b3 100644 --- a/src/macosx/native/sun/awt/LWCToolkit.m +++ b/src/macosx/native/sun/awt/LWCToolkit.m @@ -137,7 +137,7 @@ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_nativeSyncQueue if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) { NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp; [theApp postDummyEvent]; - [theApp waitForDummyEvent]; + [theApp waitForDummyEvent:timeout]; } else { // could happen if we are embedded inside SWT application, // in this case just spin a single empty block through diff --git a/src/macosx/native/sun/osxapp/NSApplicationAWT.h b/src/macosx/native/sun/osxapp/NSApplicationAWT.h index 99c7d63175a25b25712c5d57bcad3b0b2493b121..1025cd7c5330238eb9e43feb36e78e4ce2e2d52a 100644 --- a/src/macosx/native/sun/osxapp/NSApplicationAWT.h +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.h @@ -38,7 +38,7 @@ - (void) setDockIconWithEnv:(JNIEnv *)env; - (void) postDummyEvent; - (void) postRunnableEvent:(void (^)())block; -- (void) waitForDummyEvent; +- (void) waitForDummyEvent:(long long) timeout; + (void) runAWTLoopWithApp:(NSApplication*)app; diff --git a/src/macosx/native/sun/osxapp/NSApplicationAWT.m b/src/macosx/native/sun/osxapp/NSApplicationAWT.m index 21576c0b2deeb0a5dd17c37f0ac7bdd31b5c172f..aba26de17cfa1d0de1082c0022ac5c3c1f13e36a 100644 --- a/src/macosx/native/sun/osxapp/NSApplicationAWT.m +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.m @@ -397,8 +397,14 @@ AWT_ASSERT_APPKIT_THREAD; [pool drain]; } -- (void)waitForDummyEvent { - [seenDummyEventLock lockWhenCondition:YES]; +- (void)waitForDummyEvent:(long long) timeout { + if (timeout >= 0) { + double sec = ((double) timeout)/1000; + [seenDummyEventLock lockWhenCondition:YES + beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]]; + } else { + [seenDummyEventLock lockWhenCondition:YES]; + } [seenDummyEventLock unlock]; [seenDummyEventLock release];