EditorsSplitters: retrieve document in a read action
authorpeter <peter@jetbrains.com>
Thu, 22 Jan 2015 14:27:51 +0000 (15:27 +0100)
committerpeter <peter@jetbrains.com>
Thu, 22 Jan 2015 19:32:53 +0000 (20:32 +0100)
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java

index 4f89548988055a29dec66d69f1f4d8ea3b88c606..78068f695d5bb2570316993ab02fcccd7e0af121 100644 (file)
@@ -846,8 +846,13 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
         try {
           final FileEditorManagerImpl fileEditorManager = getManager();
           Element historyElement = file.getChild(HistoryEntry.TAG);
-          VirtualFile virtualFile = HistoryEntry.getVirtualFile(historyElement);
-          Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
+          final VirtualFile virtualFile = HistoryEntry.getVirtualFile(historyElement);
+          Document document = ApplicationManager.getApplication().runReadAction(new Computable<Document>() {
+            @Override
+            public Document compute() {
+              return virtualFile.isValid() ? FileDocumentManager.getInstance().getDocument(virtualFile) : null;
+            }
+          });
           final HistoryEntry entry = new HistoryEntry(fileEditorManager.getProject(), historyElement);
           final boolean isCurrentInTab = Boolean.valueOf(file.getAttributeValue(CURRENT_IN_TAB)).booleanValue();
           Boolean pin = Boolean.valueOf(file.getAttributeValue(PINNED));