提交 003e9be2 编写于 作者: L leonidr

8011695: [tck-red] Application can not be run, the Security Warning dialog is gray.

Summary: EventQueue shouldn't use AppContext.getAppContext() to obtain its AppContext.
Reviewed-by: art
上级 9dca3b09
......@@ -179,6 +179,11 @@ public class EventQueue {
*/
private volatile int waitForID;
/*
* AppContext corresponding to the queue.
*/
private final AppContext appContext;
private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement();
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
......@@ -225,8 +230,9 @@ public class EventQueue {
* completes thus causing mess in thread group to appcontext mapping.
*/
pushPopLock = (Lock)AppContext.getAppContext().get(AppContext.EVENT_QUEUE_LOCK_KEY);
pushPopCond = (Condition)AppContext.getAppContext().get(AppContext.EVENT_QUEUE_COND_KEY);
appContext = AppContext.getAppContext();
pushPopLock = (Lock)appContext.get(AppContext.EVENT_QUEUE_LOCK_KEY);
pushPopCond = (Condition)appContext.get(AppContext.EVENT_QUEUE_COND_KEY);
}
/**
......@@ -240,7 +246,7 @@ public class EventQueue {
* @throws NullPointerException if <code>theEvent</code> is <code>null</code>
*/
public void postEvent(AWTEvent theEvent) {
SunToolkit.flushPendingEvents();
SunToolkit.flushPendingEvents(appContext);
postEventPrivate(theEvent);
}
......@@ -525,7 +531,7 @@ public class EventQueue {
* of the synchronized block to avoid deadlock when
* event queues are nested with push()/pop().
*/
SunToolkit.flushPendingEvents();
SunToolkit.flushPendingEvents(appContext);
pushPopLock.lock();
try {
AWTEvent event = getNextEventPrivate();
......@@ -565,7 +571,7 @@ public class EventQueue {
* of the synchronized block to avoid deadlock when
* event queues are nested with push()/pop().
*/
SunToolkit.flushPendingEvents();
SunToolkit.flushPendingEvents(appContext);
pushPopLock.lock();
try {
for (int i = 0; i < NUM_PRIORITIES; i++) {
......@@ -873,7 +879,6 @@ public class EventQueue {
newEventQueue.previousQueue = topQueue;
topQueue.nextQueue = newEventQueue;
AppContext appContext = AppContext.getAppContext();
if (appContext.get(AppContext.EVENT_QUEUE_KEY) == topQueue) {
appContext.put(AppContext.EVENT_QUEUE_KEY, newEventQueue);
}
......@@ -934,7 +939,6 @@ public class EventQueue {
topQueue.dispatchThread.setEventQueue(prevQueue);
}
AppContext appContext = AppContext.getAppContext();
if (appContext.get(AppContext.EVENT_QUEUE_KEY) == this) {
appContext.put(AppContext.EVENT_QUEUE_KEY, prevQueue);
}
......@@ -1027,7 +1031,6 @@ public class EventQueue {
final void initDispatchThread() {
pushPopLock.lock();
try {
AppContext appContext = AppContext.getAppContext();
if (dispatchThread == null && !threadGroup.isDestroyed() && !appContext.isDisposed()) {
dispatchThread = AccessController.doPrivileged(
new PrivilegedAction<EventDispatchThread>() {
......@@ -1055,7 +1058,7 @@ public class EventQueue {
/*
* Minimize discard possibility for non-posted events
*/
SunToolkit.flushPendingEvents();
SunToolkit.flushPendingEvents(appContext);
/*
* This synchronized block is to secure that the event dispatch
* thread won't die in the middle of posting a new event to the
......@@ -1114,7 +1117,7 @@ public class EventQueue {
* <code>removeNotify</code> method.
*/
final void removeSourceEvents(Object source, boolean removeAllEvents) {
SunToolkit.flushPendingEvents();
SunToolkit.flushPendingEvents(appContext);
pushPopLock.lock();
try {
for (int i = 0; i < NUM_PRIORITIES; i++) {
......
......@@ -354,7 +354,7 @@ public class RepaintManager
// Queue a Runnable to invoke paintDirtyRegions and
// validateInvalidComponents.
scheduleProcessingRunnable();
scheduleProcessingRunnable(SunToolkit.targetToAppContext(invalidComponent));
}
......@@ -443,7 +443,7 @@ public class RepaintManager
// Queue a Runnable to invoke paintDirtyRegions and
// validateInvalidComponents.
scheduleProcessingRunnable();
scheduleProcessingRunnable(SunToolkit.targetToAppContext(c));
}
/**
......@@ -1389,10 +1389,6 @@ public class RepaintManager
return paintManager;
}
private void scheduleProcessingRunnable() {
scheduleProcessingRunnable(AppContext.getAppContext());
}
private void scheduleProcessingRunnable(AppContext context) {
if (processingRunnable.markPending()) {
Toolkit tk = Toolkit.getDefaultToolkit();
......
......@@ -97,6 +97,14 @@ public abstract class SunToolkit extends Toolkit
*/
public final static int MAX_BUTTONS_SUPPORTED = 20;
/**
* Creates and initializes EventQueue instance for the specified
* AppContext.
* Note that event queue must be created from createNewAppContext()
* only in order to ensure that EventQueue constructor obtains
* the correct AppContext.
* @param appContext AppContext to associate with the event queue
*/
private static void initEQ(AppContext appContext) {
EventQueue eventQueue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册