fixing deadlocks when isUpToDate() is called from Swing thread

This commit is contained in:
Eugene Zhuravlev
2013-01-17 13:07:40 +01:00
parent 0bec0fa361
commit cacc68e005
2 changed files with 4 additions and 1 deletions

View File

@@ -135,6 +135,7 @@ public class CompilerTask extends Task.Backgroundable {
try {
try {
final Application app = ApplicationManager.getApplication();
while (!acquired) {
acquired = semaphore.tryAcquire(500, TimeUnit.MILLISECONDS);
if (indicator.isCanceled()) {
@@ -142,6 +143,9 @@ public class CompilerTask extends Task.Backgroundable {
// let compile work begin in order to stop gracefuly on cancel event
break;
}
if (app.isDispatchThread()) {
UIUtil.dispatchAllInvocationEvents();
}
}
}
catch (InterruptedException ignored) {

View File

@@ -1529,7 +1529,6 @@ public class UIUtil {
g.setComposite(X_RENDER_ACTIVE.getValue() ? AlphaComposite.SrcOver : AlphaComposite.Src);
}
@TestOnly
public static void dispatchAllInvocationEvents() {
assert SwingUtilities.isEventDispatchThread() : Thread.currentThread();
final EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();