diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java index 8cea4bf72e94..e6e3e259b495 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java @@ -53,7 +53,6 @@ public class LaterInvocator { private static final boolean DEBUG = LOG.isDebugEnabled(); private static final Object LOCK = new Object(); - private static final IdeEventQueue ourEventQueue = IdeEventQueue.getInstance(); private LaterInvocator() { } @@ -92,8 +91,6 @@ public class LaterInvocator { private static volatile int ourQueueSkipCount; // optimization private static final FlushQueue ourFlushQueueRunnable = new FlushQueue(); - private static final Stack ourEventStack = new Stack<>(); // guarded by RUN_LOCK - private static final EventDispatcher ourModalityStateMulticaster = EventDispatcher.create(ModalityStateListener.class); public static void addModalityStateListener(@NotNull ModalityStateListener listener, @NotNull Disposable parentDisposable) { @@ -390,7 +387,6 @@ public class LaterInvocator { } private static final AtomicBoolean FLUSHER_SCHEDULED = new AtomicBoolean(false); - private static final Object RUN_LOCK = new Object(); private static class FlushQueue implements Runnable { @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized") private RunnableInfo myLastInfo; @@ -408,25 +404,16 @@ public class LaterInvocator { myLastInfo = lastInfo; if (lastInfo != null) { - synchronized (RUN_LOCK) { // necessary only because of switching to our own event queue - AWTEvent event = ourEventQueue.getTrueCurrentEvent(); - ourEventStack.push(event); - int stackSize = ourEventStack.size(); - - try { - lastInfo.runnable.run(); - lastInfo.callback.setDone(); - } - catch (ProcessCanceledException ignored) { } - catch (Throwable t) { - LOG.error(t); - } - finally { - LOG.assertTrue(ourEventStack.size() == stackSize); - ourEventStack.pop(); - - if (!DEBUG) myLastInfo = null; - } + try { + lastInfo.runnable.run(); + lastInfo.callback.setDone(); + } + catch (ProcessCanceledException ignored) { } + catch (Throwable t) { + LOG.error(t); + } + finally { + if (!DEBUG) myLastInfo = null; } } return lastInfo != null;