From b90111fc093774beaf42e8f40d8a3908940c1cac Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Thu, 29 May 2014 11:37:32 +0400 Subject: [PATCH] more reliable keeping of reference on stack (following CR-IC-5487) --- .../fileEditor/impl/EditorsSplitters.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java index 16820e15e365..3c92cd2eb520 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java @@ -34,10 +34,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.*; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.FocusWatcher; @@ -77,6 +74,8 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener private static final String PINNED = "pinned"; private static final String CURRENT_IN_TAB = "current-in-tab"; + private static final Key DUMMY_KEY = Key.create("EditorsSplitters.dummy.key"); + private final static EditorEmptyTextPainter ourPainter = ServiceManager.getService(EditorEmptyTextPainter.class); private EditorWindow myCurrentWindow; @@ -841,9 +840,7 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener final FileEditorManagerImpl fileEditorManager = getManager(); Element historyElement = file.getChild(HistoryEntry.TAG); VirtualFile virtualFile = HistoryEntry.getVirtualFile(historyElement); - // This document reference is kept on stack to make sure document will be available for folding state deserialization - // and that document will be created only once during file opening - @SuppressWarnings("UnusedDeclaration") Document document = FileDocumentManager.getInstance().getDocument(virtualFile); + Document document = FileDocumentManager.getInstance().getDocument(virtualFile); final HistoryEntry entry = new HistoryEntry(fileEditorManager.getProject(), historyElement); final boolean isCurrentInTab = Boolean.valueOf(file.getAttributeValue(CURRENT_IN_TAB)).booleanValue(); final int index = i; @@ -856,6 +853,12 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener } } }); + if (document != null) { + // This is just to make sure document reference is kept on stack till this point + // so that document is available for folding state deserialization in HistoryEntry constructor + // and that document will be created only once during file opening + document.putUserData(DUMMY_KEY, null); + } updateProgress(); } catch (InvalidDataException e) {