From b223031507091aca90ca0b094fcc6bf1b2670449 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 24 Feb 2009 20:16:05 +0300 Subject: [PATCH] already disposed --- .../codeInsight/highlighting/BraceHighlightingHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java b/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java index 2892d71953..3d7c54c988 100644 --- a/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java +++ b/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java @@ -75,6 +75,7 @@ public class BraceHighlightingHandler { Job job = JobScheduler.getInstance().createJob("Brace highlighter", Job.DEFAULT_PRIORITY); job.addTask(new Runnable() { public void run() { + if (isReallyDisposed(editor, project)) return; final PsiFile injected = ApplicationManager.getApplication().runReadAction(new Computable() { public PsiFile compute() { Document document = editor.getDocument(); @@ -84,8 +85,7 @@ public class BraceHighlightingHandler { }); ApplicationManager.getApplication().invokeLater(new Runnable(){ public void run() { - Project editorProject = editor.getProject(); - if (editorProject != null && !editorProject.isDisposed() && !project.isDisposed() && editor.getComponent().isShowing() && !editor.isViewer()) { + if (!isReallyDisposed(editor, project)) { Editor newEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injected); BraceHighlightingHandler handler = new BraceHighlightingHandler(project, newEditor, alarm, injected); processor.process(handler); @@ -97,6 +97,12 @@ public class BraceHighlightingHandler { job.schedule(); } + private static boolean isReallyDisposed(Editor editor, Project project) { + Project editorProject = editor.getProject(); + return editorProject == null || + editorProject.isDisposed() || project.isDisposed() || !editor.getComponent().isShowing() || editor.isViewer(); + } + static PsiFile getInjectedFileIfAny(@NotNull final Editor editor, @NotNull final Project project, int offset, @NotNull PsiFile psiFile, @NotNull final Alarm alarm) { Document document = editor.getDocument(); // when document is committed, try to highlight braces in injected lang - it's fast -- 2.11.4.GIT