From f96de92eab2cb18caa5be24f6f16f52b131416e6 Mon Sep 17 00:00:00 2001 From: Kirill Timofeev Date: Mon, 12 Nov 2018 17:54:19 +0300 Subject: [PATCH] platform: add `makeCurrentMessageDialogGoAway` to the end of event queue When we show message dialog on mac we use `SheetMessage`, that create dialog in three steps: 1. Create JDialog and calculate components size 2. Start animation calling `startAnimation` 3. When animation is finished set JDialog component to what it should be The problem is: if we call `makeCurrentMessageDialogGoAway` using `UIUtil.invokeLaterIfNeeded` it will be invoked before animation stopped and won't find cancel button, which is the only way to close the dialog. Force add event to the end of queue may fix this problem in some cases. --- .../platform-api/src/com/intellij/openapi/ui/Messages.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 6867c4f66661..f786116adf57 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -177,7 +177,8 @@ public class Messages { @NotNull public static Runnable createMessageDialogRemover(@Nullable Project project) { Window projectWindow = project == null ? null : WindowManager.getInstance().suggestParentWindow(project); - return () -> UIUtil.invokeLaterIfNeeded(() -> makeCurrentMessageDialogGoAway( + //noinspection SSBasedInspection + return () -> SwingUtilities.invokeLater(() -> makeCurrentMessageDialogGoAway( projectWindow != null ? projectWindow.getOwnedWindows() : Window.getWindows())); }