2228674: Fix failed for CR 7162144

Reviewed-by: art, anthony
This commit is contained in:
Oleg Pekhovskiy 2013-10-16 19:02:10 +04:00
parent 6b7c3f5384
commit f888e8419e
2 changed files with 15 additions and 42 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,19 +25,11 @@
package java.awt;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.lang.reflect.Method;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
import sun.awt.AWTAutoShutdown;
import sun.awt.SunToolkit;
import sun.awt.AppContext;
import java.util.ArrayList;
import java.util.List;
import sun.util.logging.PlatformLogger;
import sun.awt.dnd.SunDragSourceContextPeer;
@ -67,8 +59,7 @@ class EventDispatchThread extends Thread {
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
private EventQueue theQueue;
private boolean doDispatch = true;
private volatile boolean shutdown = false;
private volatile boolean doDispatch = true;
private static final int ANY_EVENT = -1;
@ -86,24 +77,15 @@ class EventDispatchThread extends Thread {
doDispatch = false;
}
public void interrupt() {
shutdown = true;
super.interrupt();
}
public void run() {
while (true) {
try {
pumpEvents(new Conditional() {
public boolean evaluate() {
return true;
}
});
} finally {
if(getEventQueue().detachDispatchThread(this, shutdown)) {
break;
try {
pumpEvents(new Conditional() {
public boolean evaluate() {
return true;
}
}
});
} finally {
getEventQueue().detachDispatchThread(this);
}
}
@ -130,8 +112,7 @@ class EventDispatchThread extends Thread {
void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
addEventFilter(filter);
doDispatch = true;
shutdown |= isInterrupted();
while (doDispatch && !shutdown && cond.evaluate()) {
while (doDispatch && !isInterrupted() && cond.evaluate()) {
pumpOneEventForFilters(id);
}
removeEventFilter(filter);
@ -223,12 +204,12 @@ class EventDispatchThread extends Thread {
}
}
catch (ThreadDeath death) {
shutdown = true;
doDispatch = false;
throw death;
}
catch (InterruptedException interruptedException) {
shutdown = true; // AppContext.dispose() interrupts all
// Threads in the AppContext
doDispatch = false; // AppContext.dispose() interrupts all
// Threads in the AppContext
}
catch (Throwable e) {
processException(e);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1074,7 +1074,7 @@ public class EventQueue {
}
}
final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) {
final void detachDispatchThread(EventDispatchThread edt) {
/*
* Minimize discard possibility for non-posted events
*/
@ -1090,17 +1090,9 @@ public class EventQueue {
pushPopLock.lock();
try {
if (edt == dispatchThread) {
/*
* Don't detach the thread if any events are pending. Not
* sure if it's a possible scenario, though.
*/
if (!forceDetach && (peekEvent() != null)) {
return false;
}
dispatchThread = null;
}
AWTAutoShutdown.getInstance().notifyThreadFree(edt);
return true;
} finally {
pushPopLock.unlock();
}