From 75464f5cd2f1a933a2cf1bef69b24954c1f2f633 Mon Sep 17 00:00:00 2001 From: Evgenii Novozhilov Date: Fri, 6 Sep 2024 17:38:52 +0300 Subject: [PATCH] clion: fix UI call on non-UI thread after 2024.2 CLion invokes createProcess on a background thread, so UI access is no longer allowed in this context. fix is backward compatible as we're allowed to use invokeAndWait on EDT as well. fixes #6740 --- .../blaze/clwb/run/BlazeCidrLauncher.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java b/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java index 43b0064391c..662c4db0cc5 100644 --- a/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java +++ b/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java @@ -59,6 +59,7 @@ import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.ui.ConsoleView; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.xdebugger.XDebugSession; @@ -135,26 +136,28 @@ private ProcessHandler createProcess(CommandLineState state, List extraB Preconditions.checkNotNull(ProjectViewManager.getInstance(project).getProjectViewSet()); if (shouldDisplayBazelTestFilterWarning()) { - String messageContents = - "The Google Test framework did not apply test filtering correctly before " - + "git commit ba96d0b.
" - + "Please ensure you are past this commit if you are using it.

" - + "More information on the bazel
issue"; - - int selectedOption = - Messages.showDialog( - getProject(), - messageContents, - "Please update 'Google Test' past ba96d0b...", - new String[] {"Close", "Don't show again"}, - 0, // Default to "Close" - Messages.getWarningIcon()); - if (selectedOption == 1) { - PropertiesComponent.getInstance().setValue(DISABLE_BAZEL_GOOGLETEST_FILTER_WARNING, "true"); - } + ApplicationManager.getApplication().invokeAndWait(() -> { + String messageContents = + "The Google Test framework did not apply test filtering correctly before " + + "git commit ba96d0b.
" + + "Please ensure you are past this commit if you are using it.

" + + "More information on the bazel
issue"; + + int selectedOption = + Messages.showDialog( + getProject(), + messageContents, + "Please update 'Google Test' past ba96d0b...", + new String[] {"Close", "Don't show again"}, + 0, // Default to "Close" + Messages.getWarningIcon()); + if (selectedOption == 1) { + PropertiesComponent.getInstance().setValue(DISABLE_BAZEL_GOOGLETEST_FILTER_WARNING, "true"); + } + }); } BlazeCommand.Builder commandBuilder =