diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2019-07-03 23:31:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 23:31:18 +0300 |
commit | 378dc27434b11684decdaf7517ca1023166bad33 (patch) | |
tree | 340d5b5d446510a30cdffeabc9748c3a125414bd | |
parent | 1ef7211af3d7cf68aa7799cc62e6029526254629 (diff) | |
parent | 56dcdf859aaca30a60ecb83f91e8ecf56a597710 (diff) |
Merge pull request #8125 from mono/backport-pr-8067-to-release-8.2
[release-8.2] Fixes VSTS Bug 937036: [FATAL] System.NullReferenceException exception in MonoDevelop.Ide.Gui.DefaultWorkbench.get_Memento()
4 files changed, 24 insertions, 12 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/DefaultWorkbench.cs index f7373dd586..2c477f3d1f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/DefaultWorkbench.cs @@ -567,12 +567,13 @@ namespace MonoDevelop.Ide.Gui GetSize (out int width, out int height); // HACK: always capture bounds on OS X because we don't restore Gdk.WindowState.Maximized due to // the bug mentioned below. So we simular Maximized by capturing the Maximized size. - if (GdkWindow.State == 0 || Platform.IsMac) { + if (GdkWindow?.State == 0 || Platform.IsMac) { memento.Bounds = new Rectangle (x, y, width, height); } else { memento.Bounds = requestedBounds; } - memento.WindowState = GdkWindow.State; + if (GdkWindow != null) + memento.WindowState = GdkWindow.State; memento.FullScreen = FullScreen; return memento.ToProperties (); } @@ -641,7 +642,13 @@ namespace MonoDevelop.Ide.Gui BrandingService.ApplicationNameChanged -= ApplicationNameChanged; if (initialized) { - PropertyService.Set ("SharpDevelop.Workbench.WorkbenchMemento", this.Memento); + try { + if (GdkWindow != null) + PropertyService.Set ("SharpDevelop.Workbench.WorkbenchMemento", Memento); + } catch (Exception e) { + LoggingService.LogInternalError ("Error while creating the workbench preferences.", e); + } + //don't allow the "full view" layouts to persist - they are always derived from the "normal" layout foreach (var fv in dock.Layouts) if (fv.EndsWith (fullViewModeTag)) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index 0c2d947feb..74bdc40b31 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -194,7 +194,7 @@ namespace MonoDevelop.Ide.Gui if (!IdeApp.OnExit ()) return false; - IdeApp.Workspace.SavePreferences (); + await IdeApp.Workspace.SavePreferencesAsync (); bool showDirtyDialog = false; @@ -223,8 +223,6 @@ namespace MonoDevelop.Ide.Gui workbench.Close (); - IdeApp.Workspace.SavePreferences (); - IdeApp.OnExited (); IdeApp.CommandService.Dispose (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs index 18571ae0c7..8f2ac13ba8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs @@ -337,7 +337,7 @@ namespace MonoDevelop.Ide await SaveAsync (((SolutionFolderItem)item).ParentSolution); } else { await workspace.SaveAsync (); - workspace.SavePreferences (); + await workspace.SavePreferencesAsync (); } } @@ -618,7 +618,7 @@ namespace MonoDevelop.Ide } } await SaveAsync (selectedProject); - workspace.SavePreferences (); + await workspace.SavePreferencesAsync (); IdeApp.Workbench.ReparseOpenDocuments (); } } finally { @@ -655,7 +655,7 @@ namespace MonoDevelop.Ide if (si.ParentSolution != null) await SaveAsync (si.ParentSolution); } - workspace.SavePreferences (); + await workspace.SavePreferencesAsync (); } } finally { optionsDialog.Destroy (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs index ed963c81c9..68f4f7b00c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs @@ -491,12 +491,19 @@ namespace MonoDevelop.Ide #region Opening and closing + [Obsolete("Use SavePreferencesAync")] public void SavePreferences () { foreach (WorkspaceItem it in Items) SavePreferences (it); } - + + internal async Task SavePreferencesAsync () + { + foreach (WorkspaceItem it in Items) + await SavePreferences (it); + } + public async Task<bool> Close () { return await Close (true); @@ -521,7 +528,7 @@ namespace MonoDevelop.Ide } if (saveWorkspacePreferencies) - SavePreferences (); + await SavePreferencesAsync (); if (closeProjectFiles && documentManager != null) { foreach (Document doc in documentManager.Documents.ToArray ()) { @@ -991,7 +998,7 @@ namespace MonoDevelop.Ide string file = item.FileName; try { SetReloading (true); - SavePreferences (); + await SavePreferencesAsync (); await CloseWorkspaceItem (item, false); await OpenWorkspaceItem (file, false, false); } finally { |