From 60843512c69af574b68183a21549fdd2ad8eb6c0 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 8 May 2020 16:27:55 +0200 Subject: [PATCH] Ensure that we remove editor reference from myActiveEditors when editor is released (IDEA-240456) GitOrigin-RevId: 541df88c4b136a3cab8d9f1d529656217bcd4351 --- .../com/intellij/codeInsight/daemon/impl/DaemonListeners.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index 0f9850ce4d2f..9adfba618ad3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -84,6 +84,7 @@ import org.jetbrains.annotations.Nullable; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -169,7 +170,7 @@ public final class DaemonListeners implements Disposable { return; } - myActiveEditors = activeEditors; + myActiveEditors = new ArrayList<>(activeEditors); // do not stop daemon if idea loses/gains focus DaemonListeners.this.stopDaemon(true, "Active editor change"); if (ApplicationManager.getApplication().isDispatchThread() && LaterInvocator.isInModalContext()) { @@ -209,6 +210,7 @@ public final class DaemonListeners implements Disposable { @Override public void editorReleased(@NotNull EditorFactoryEvent event) { + myActiveEditors.remove(event.getEditor()); // mem leak after closing last editor otherwise UIUtil.invokeLaterIfNeeded(() -> { IntentionsUI intentionUI = myProject.getServiceIfCreated(IntentionsUI.class);