mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
7177040: Deadlock between PostEventQueue.noEvents, EventQueue.isDispatchThread and SwingUtilities.invokeLater
Reviewed-by: anthony, ant
This commit is contained in:
parent
80c6175a2a
commit
e99cc14fc5
1 changed files with 23 additions and 7 deletions
|
@ -2112,27 +2112,43 @@ class PostEventQueue {
|
|||
private EventQueueItem queueTail = null;
|
||||
private final EventQueue eventQueue;
|
||||
|
||||
// For the case when queue is cleared but events are not posted
|
||||
private volatile boolean isFlushing = false;
|
||||
|
||||
PostEventQueue(EventQueue eq) {
|
||||
eventQueue = eq;
|
||||
}
|
||||
|
||||
public synchronized boolean noEvents() {
|
||||
return queueHead == null;
|
||||
return queueHead == null && !isFlushing;
|
||||
}
|
||||
|
||||
/*
|
||||
* Continually post pending AWTEvents to the Java EventQueue. The method
|
||||
* is synchronized to ensure the flush is completed before a new event
|
||||
* can be posted to this queue.
|
||||
*
|
||||
* 7177040: The method couldn't be wholly synchronized because of calls
|
||||
* of EventQueue.postEvent() that uses pushPopLock, otherwise it could
|
||||
* potentially lead to deadlock
|
||||
*/
|
||||
public synchronized void flush() {
|
||||
EventQueueItem tempQueue = queueHead;
|
||||
public void flush() {
|
||||
EventQueueItem tempQueue;
|
||||
synchronized (this) {
|
||||
tempQueue = queueHead;
|
||||
queueHead = queueTail = null;
|
||||
isFlushing = true;
|
||||
}
|
||||
try {
|
||||
while (tempQueue != null) {
|
||||
eventQueue.postEvent(tempQueue.event);
|
||||
tempQueue = tempQueue.next;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
isFlushing = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Enqueue an AWTEvent to be posted to the Java EventQueue.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue