mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-147973 Memory leak detected in QuickEditHandler
This commit is contained in:
@@ -30,6 +30,8 @@ import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.openapi.editor.actionSystem.ReadonlyFragmentModificationHandler;
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.event.EditorFactoryAdapter;
|
||||
import com.intellij.openapi.editor.event.EditorFactoryEvent;
|
||||
import com.intellij.openapi.editor.ex.DocumentEx;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
@@ -38,6 +40,7 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWindow;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite;
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
@@ -134,6 +137,26 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
|
||||
myOrigCreationStamp = myOrigDocument.getModificationStamp(); // store creation stamp for UNDO tracking
|
||||
myOrigDocument.addDocumentListener(this, this);
|
||||
myNewDocument.addDocumentListener(this, this);
|
||||
EditorFactory editorFactory = ObjectUtils.assertNotNull(EditorFactory.getInstance());
|
||||
// not FileEditorManager listener because of RegExp checker and alike
|
||||
editorFactory.addEditorFactoryListener(new EditorFactoryAdapter() {
|
||||
int useCount;
|
||||
|
||||
@Override
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
if (event.getEditor().getDocument() != myNewDocument) return;
|
||||
useCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editorReleased(@NotNull EditorFactoryEvent event) {
|
||||
if (event.getEditor().getDocument() != myNewDocument) return;
|
||||
if (--useCount > 0) return;
|
||||
if (Boolean.TRUE.equals(myNewVirtualFile.getUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN))) return;
|
||||
|
||||
Disposer.dispose(QuickEditHandler.this);
|
||||
}
|
||||
}, this);
|
||||
|
||||
if ("JAVA".equals(firstShred.getHost().getLanguage().getID())) {
|
||||
PsiLanguageInjectionHost.Shred lastShred = ContainerUtil.getLastItem(shreds);
|
||||
|
||||
Reference in New Issue
Block a user