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