mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-25 09:40:10 +00:00
7171163: [macosx] Shortcomings in the design of the secondary native event loop made JavaFX DnD deadlock
Reviewed-by: anthony, art
This commit is contained in:
parent
4529bcedea
commit
8f4a77bfef
@ -41,10 +41,11 @@ final class CToolkitThreadBlockedHandler implements ToolkitThreadBlockedHandler
|
||||
}
|
||||
|
||||
public void enter() {
|
||||
toolkit.startNativeNestedEventLoop();
|
||||
// Execute the next AppKit event while we are waiting for system to
|
||||
// finish our request - this will save us from biting our own tail
|
||||
toolkit.executeNextAppKitEvent();
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
toolkit.stopNativeNestedEventLoop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,9 +63,7 @@ public class LWCToolkit extends LWToolkit {
|
||||
|
||||
private static native void initIDs();
|
||||
|
||||
static native void startNativeNestedEventLoop();
|
||||
|
||||
static native void stopNativeNestedEventLoop();
|
||||
static native void executeNextAppKitEvent();
|
||||
|
||||
private static CInputMethodDescriptor sInputMethodDescriptor;
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@ jint* gButtonDownMasks;
|
||||
@implementation AWTToolkit
|
||||
|
||||
static long eventCount;
|
||||
static bool shouldKeepRunningNestedLoop = NO;
|
||||
|
||||
+ (long) getEventCount{
|
||||
return eventCount;
|
||||
@ -460,33 +459,18 @@ Java_sun_font_FontManager_populateFontFileNameMap
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: startNativeNestedEventLoop
|
||||
* Method: executeNextAppKitEvent
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_startNativeNestedEventLoop
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_executeNextAppKitEvent
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
if(!shouldKeepRunningNestedLoop) {
|
||||
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
||||
NSApplication * app = [NSApplication sharedApplication];
|
||||
shouldKeepRunningNestedLoop = YES;
|
||||
while (shouldKeepRunningNestedLoop && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]])
|
||||
{
|
||||
NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
|
||||
if (event != nil) {
|
||||
[app sendEvent: event];
|
||||
}
|
||||
}
|
||||
// Simply get the next event in native loop and pass it to execution
|
||||
// We'll be called repeatedly so there's no need to block here
|
||||
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
||||
NSApplication * app = [NSApplication sharedApplication];
|
||||
NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
|
||||
if (event != nil) {
|
||||
[app sendEvent: event];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: stopNativeNestedEventLoop
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopNativeNestedEventLoop
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
shouldKeepRunningNestedLoop = NO;
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||
postDropTargetEvent(component, x, y, dropAction, actions,
|
||||
formats, nativeCtxt,
|
||||
SunDropTargetEvent.MOUSE_DROPPED,
|
||||
!SunDropTargetContextPeer.DISPATCH_SYNC);
|
||||
SunDropTargetContextPeer.DISPATCH_SYNC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user