From c2d7f4eb12bb30c026eeefed23b340966bb16a74 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 21 Sep 2016 15:29:20 +0300 Subject: [PATCH] IDEA-161519 java.lang.IllegalStateException: The DialogWrapper can only be used in event dispatch... --- .../openapi/wm/impl/CommandProcessor.java | 19 ++++++++----------- .../wm/impl/commands/InvokeLaterCmd.java | 14 +++++++++----- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java index 129ea9c06b97..f79f60d4330b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java @@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Conditions; import com.intellij.openapi.wm.impl.commands.FinalizableCommand; -import com.intellij.util.ui.EdtInvocationManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,19 +44,17 @@ public final class CommandProcessor implements Runnable { * prevent focus handling of events which is caused by the commands to be executed. */ public final void execute(@NotNull List commandList, @NotNull Condition expired) { - EdtInvocationManager.getInstance().invokeLater(() -> { - synchronized (myLock) { - final boolean isBusy = myCommandCount > 0; + synchronized (myLock) { + final boolean isBusy = myCommandCount > 0; - final CommandGroup commandGroup = new CommandGroup(commandList, expired); - myCommandGroupList.add(commandGroup); - myCommandCount += commandList.size(); + final CommandGroup commandGroup = new CommandGroup(commandList, expired); + myCommandGroupList.add(commandGroup); + myCommandCount += commandList.size(); - if (!isBusy) { - run(); - } + if (!isBusy) { + run(); } - }); + } } public final void run() { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/commands/InvokeLaterCmd.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/commands/InvokeLaterCmd.java index 09cf1f257bc9..d8115ab372e5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/commands/InvokeLaterCmd.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/commands/InvokeLaterCmd.java @@ -16,6 +16,7 @@ package com.intellij.openapi.wm.impl.commands; +import com.intellij.util.ui.EdtInvocationManager; /** * @author Vladimir Kondratyev @@ -29,11 +30,14 @@ public final class InvokeLaterCmd extends FinalizableCommand{ } public void run(){ - try{ - myRunnable.run(); - }finally{ - finish(); - } + EdtInvocationManager.getInstance().invokeLater(() -> { + try { + myRunnable.run(); + } + finally { + finish(); + } + }); } @Override