From 6ce0bde199d6a73bf1ceee4262fb9b2a1a015385 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 3 Mar 2017 09:15:51 +0100 Subject: [PATCH] if doWhenFocusSettlesDown can run immediately, execute just the given request don't run everything else that's queued, because it might lead to unexpected actions being performed in wrong contexts (e.g. EA-97139 - assert: NoSwingUnderWriteAction.a) --- .../src/com/intellij/openapi/wm/impl/FocusManagerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java index 9e1aad6d72e2..dd64bd86b6d1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java @@ -468,13 +468,14 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable { @Override public void doWhenFocusSettlesDown(@NotNull final Runnable runnable) { + boolean invokedOnEdt = ApplicationManager.getApplication().isDispatchThread(); UIUtil.invokeLaterIfNeeded(() -> { if (isFlushingIdleRequests()) { myIdleRequests.add(runnable); return; } - if (myRunContext != null) { + if (myRunContext != null || invokedOnEdt && canFlushIdleRequests()) { flushRequest(runnable); return; }