diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 66b6c2ee7..a540cb6e3 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -340,8 +340,15 @@ namespace MatterHackers.MatterControl return popupMenu; } - public void PersistUserTabs() + public async Task PersistUserTabs() { + // Persist all pending changes in all workspaces to disk + foreach (var workspace in this.Workspaces) + { + await this.Tasks.Execute("Saving ".Localize() + $" \"{workspace.Name}\" ...", workspace, workspace.SceneContext.SaveChanges); + } + + // Project workspace definitions to serializable structure var workspaces = this.Workspaces.Select(w => { if (w.Printer == null) @@ -360,7 +367,7 @@ namespace MatterHackers.MatterControl } }); - // Persist part workspaces + // Persist workspace definitions to disk File.WriteAllText( ProfileManager.Instance.OpenTabsPath, JsonConvert.SerializeObject( diff --git a/MatterControlLib/RootSystemWindow.cs b/MatterControlLib/RootSystemWindow.cs index de5f38370..51a03f0a7 100644 --- a/MatterControlLib/RootSystemWindow.cs +++ b/MatterControlLib/RootSystemWindow.cs @@ -297,29 +297,17 @@ namespace MatterHackers.MatterControl // cancel the close so that we can save all our active work spaces eventArgs.Cancel = true; - ApplicationController.Instance.PersistUserTabs(); - UiThread.RunOnIdle(async () => { var application = ApplicationController.Instance; - // Save changes before close - foreach (var printer in ApplicationController.Instance.ActivePrinters) - { - if (printer != PrinterConfig.EmptyPrinter) - { - await application.Tasks.Execute("Saving Print Bed".Localize() + "...", printer, printer.Bed.SaveChanges); - } - } - - foreach (var workspace in application.Workspaces) - { - await application.Tasks.Execute("Saving Print Bed".Localize() + "...", workspace, workspace.SceneContext.SaveChanges); - } + await application.PersistUserTabs(); application.ApplicationExiting = true; + // Make sure we tell the Application Controller to shut down. This will release the slicing thread if running. application.Shutdown(); + this.CloseOnIdle(); }); } diff --git a/MatterControlLib/Utilities/AuthenticationData.cs b/MatterControlLib/Utilities/AuthenticationData.cs index 65859f90f..a8e66b1d9 100644 --- a/MatterControlLib/Utilities/AuthenticationData.cs +++ b/MatterControlLib/Utilities/AuthenticationData.cs @@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl ApplicationController.Instance.ChangeCloudSyncStatus(userAuthenticated: true); AuthSessionChanged.CallEvents(null, null); } - + public bool ClientAuthenticatedSessionValid { get