From c6885b51e28c39cb6a325ea95d72d210d39acaa4 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 6 Sep 2006 18:18:31 +0000 Subject: [PATCH] Prevent disposing and recreating WorkbenchWindows on layout change. Fixes SD2-1003. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1771 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs | 3 ++- .../Src/Gui/Workbench/Layouts/LayoutConfiguration.cs | 12 +++++++----- .../Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs | 7 ++++--- .../Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs | 6 +++++- .../FindReferencesAndRenameHelper.cs | 3 +-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs b/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs index 0ee6ea97ef..a38b8a2ba8 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs @@ -47,8 +47,9 @@ namespace ICSharpCode.SharpDevelop.Gui } */ - /// + /// /// The current view content which is shown inside this window. + /// This method is thread-safe. /// IBaseViewContent ActiveViewContent { get; diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs index 65e63b7338..a8dac24b10 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs @@ -198,11 +198,13 @@ namespace ICSharpCode.SharpDevelop.Gui w.Formatting = Formatting.Indented; w.WriteStartElement("LayoutConfig"); foreach (LayoutConfiguration lc in Layouts) { - w.WriteStartElement("Layout"); - w.WriteAttributeString("name", lc.name); - w.WriteAttributeString("file", lc.fileName); - w.WriteAttributeString("readonly", lc.readOnly.ToString()); - w.WriteEndElement(); + if (lc.custom) { + w.WriteStartElement("Layout"); + w.WriteAttributeString("name", lc.name); + w.WriteAttributeString("file", lc.fileName); + w.WriteAttributeString("readonly", lc.readOnly.ToString()); + w.WriteEndElement(); + } } w.WriteEndElement(); } diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs index 9647df8e8c..be7a3e5561 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs @@ -245,8 +245,8 @@ namespace ICSharpCode.SharpDevelop.Gui IViewContent activeView = GetActiveView(); dockPanel.ActiveDocumentChanged -= new EventHandler(ActiveMdiChanged); - DetachPadContents(true); - DetachViewContents(true); + DetachPadContents(false); + DetachViewContents(false); dockPanel.ActiveDocumentChanged += new EventHandler(ActiveMdiChanged); LoadLayoutConfiguration(); @@ -448,7 +448,8 @@ namespace ICSharpCode.SharpDevelop.Gui } if (!contentHash.ContainsKey(content.Class)) { DockContent newContent = CreateContent(content); - newContent.Show(dockPanel); + // TODO: read the default dock state from the PadDescriptor + newContent.Show(dockPanel, DockState.Hidden); } else { contentHash[content.Class].Show(); } diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs index d361f232b3..1ebf441308 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs @@ -56,6 +56,10 @@ namespace ICSharpCode.SharpDevelop.Gui } } + /// + /// The current view content which is shown inside this window. + /// This method is thread-safe. + /// public IBaseViewContent ActiveViewContent { get { if (viewTabControl != null) { @@ -317,7 +321,7 @@ namespace ICSharpCode.SharpDevelop.Gui IBaseViewContent GetSubViewContent(int index) { - if (index == 0) + if (index == 0 || content == null) return content; else return content.SecondaryViewContents[index - 1]; diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs b/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs index 0839b7be43..e7e6d6cef6 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs @@ -255,8 +255,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring List modifiedContents = new List(); List modifications = new List(); foreach (Reference r in list) { - FileService.OpenFile(r.FileName); - IViewContent viewContent = FileService.GetOpenFile(r.FileName).ViewContent; + IViewContent viewContent = FileService.OpenFile(r.FileName).ViewContent; if (!modifiedContents.Contains(viewContent)) { modifiedContents.Add(viewContent); }