[threading] IJPL-226794: Wrap disposal of popups into write-intent read action

GitOrigin-RevId: d5e0f4f42d0d21267560c5553715f5b17ea503ae
This commit is contained in:
Konstantin Nisht
2026-01-05 17:33:42 +00:00
committed by intellij-monorepo-bot
parent 0b021032a9
commit 12e9b158ac
2 changed files with 6 additions and 4 deletions
@@ -1,7 +1,8 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.ui.popup;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.WriteIntentReadAction;
import com.intellij.openapi.ui.GenericListComponentUpdater;
import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.Computable;
@@ -203,7 +204,7 @@ public class PopupChooserBuilder<T> implements IPopupChooserBuilder<T> {
public PopupChooserBuilder<T> setItemChosenCallback(@NotNull Runnable runnable) {
myItemChosenRunnable = () -> {
try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) {
runnable.run();
WriteIntentReadAction.run(runnable);
}
};
return this;
@@ -1,4 +1,4 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui.popup;
import com.google.common.base.Predicate;
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.impl.AutoPopupSupportingListener;
import com.intellij.openapi.actionSystem.impl.Utils;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteIntentReadAction;
import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -2081,7 +2082,7 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer, AlignedPopup
Runnable finalRunnable = myFinalRunnable;
getFocusManager().doWhenFocusSettlesDown(() -> {
try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) {
finalRunnable.run();
WriteIntentReadAction.run(finalRunnable);
}
});
myFinalRunnable = null;