提交 888d88a1 编写于 作者: K kizune

7171163: [macosx] Shortcomings in the design of the secondary native event...

7171163: [macosx] Shortcomings in the design of the secondary native event loop made JavaFX DnD deadlock
Reviewed-by: anthony, art
上级 56cb8467
......@@ -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) {
// 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];
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];
}
}
}
}
/*
* 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);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册