Made to so we save all workspaces before exit

issue: MatterHackers/MCCentral#4318
Part tab fails to persist on close
This commit is contained in:
Lars Brubaker 2018-11-07 14:41:11 -08:00
parent 249275ea98
commit d2f6dcf8bc
5 changed files with 30 additions and 14 deletions

View file

@ -1547,7 +1547,7 @@ namespace MatterHackers.MatterControl
return mappedEditors; return mappedEditors;
} }
internal void Shutdown() public void Shutdown()
{ {
// Ensure all threads shutdown gracefully on close // Ensure all threads shutdown gracefully on close
@ -1757,13 +1757,6 @@ namespace MatterHackers.MatterControl
{ {
this.Thumbnails.Shutdown(); this.Thumbnails.Shutdown();
// Save changes before close
if (this.ActivePrinter != null
&& this.ActivePrinter != PrinterConfig.EmptyPrinter)
{
await this.ActivePrinter.Bed.SaveChanges(null, CancellationToken.None);
}
ApplicationSettings.Instance.ReleaseClientToken(); ApplicationSettings.Instance.ReleaseClientToken();
} }

View file

@ -289,12 +289,34 @@ namespace MatterHackers.MatterControl
StyledMessageBox.MessageType.YES_NO_WITHOUT_HIGHLIGHT); StyledMessageBox.MessageType.YES_NO_WITHOUT_HIGHLIGHT);
}); });
} }
else else if(!ApplicationController.Instance.ApplicationExiting)
{ {
ApplicationController.Instance.ApplicationExiting = true; // cancel the close so that we can save all our active work spaces
// Make sure we tell the Application Controller to shut down. This will release the slicing thread if running. eventArgs.Cancel = true;
ApplicationController.Instance.Shutdown();
UiThread.RunOnIdle(async () =>
{
var application = ApplicationController.Instance;
// Save changes before close
if (application.ActivePrinter != null
&& application.ActivePrinter != PrinterConfig.EmptyPrinter)
{
await application.Tasks.Execute("Saving Print Bed".Localize() + "...", application.ActivePrinter.Bed.SaveChanges);
}
foreach (var workspace in application.Workspaces)
{
await application.Tasks.Execute("Saving Print Bed".Localize() + "...", workspace.SceneContext.SaveChanges);
}
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();
});
} }
// we are exiting and have finished saving
} }
public override void OnClosed(EventArgs e) public override void OnClosed(EventArgs e)

View file

@ -75,6 +75,7 @@ namespace MatterHackers.MatterControl
config.Bind("Agg:GraphicsMode", AggContext.Config.GraphicsMode); config.Bind("Agg:GraphicsMode", AggContext.Config.GraphicsMode);
Slicer.RunInProcess = config.GetValue<bool>("MatterControl:Slicer:Debug"); Slicer.RunInProcess = config.GetValue<bool>("MatterControl:Slicer:Debug");
Slicer.RunInProcess = true;
// Make sure we have the right working directory as we assume everything relative to the executable. // Make sure we have the right working directory as we assume everything relative to the executable.
Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));

@ -1 +1 @@
Subproject commit fafbca2512fb34724eca996fc3fe4ba489b27ae7 Subproject commit ac9ff0914ad8b0a2c379ef47657f051f4e1edfa0

@ -1 +1 @@
Subproject commit 7af8c7cde04feba99adf51d85ac90d413bd7992b Subproject commit 190c148a7494d0a13ee318f5f3a80dc9f6989e61