From 4d345c73ee0b6cd4f4c849955c8ef3c0cc78ffca Mon Sep 17 00:00:00 2001 From: jlewin Date: Mon, 6 May 2019 16:03:13 -0700 Subject: [PATCH] Prevent GCode load during slicing - Issue MatterHackers/MCCentral#5453 Crash after switching to 3D GCode view while slicing --- MatterControlLib/ApplicationView/ApplicationController.cs | 4 ++++ MatterControlLib/ApplicationView/BedConfig.cs | 1 + MatterControlLib/ApplicationView/PrinterViewState.cs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 490713212..c5466ca76 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -2606,6 +2606,8 @@ namespace MatterHackers.MatterControl // Slice bool slicingSucceeded = false; + printer.ViewState.SlicingItem = true; + await this.Tasks.Execute("Slicing".Localize(), printer, async (reporter, cancellationToken) => { slicingSucceeded = await Slicer.SliceItem( @@ -2616,6 +2618,8 @@ namespace MatterHackers.MatterControl cancellationToken); }); + printer.ViewState.SlicingItem = false; + // Skip loading GCode output if slicing failed if (!slicingSucceeded) { diff --git a/MatterControlLib/ApplicationView/BedConfig.cs b/MatterControlLib/ApplicationView/BedConfig.cs index bac808cd6..f24aa54bf 100644 --- a/MatterControlLib/ApplicationView/BedConfig.cs +++ b/MatterControlLib/ApplicationView/BedConfig.cs @@ -369,6 +369,7 @@ namespace MatterHackers.MatterControl internal void EnsureGCodeLoaded() { if (this.LoadedGCode == null + && !this.Printer.ViewState.SlicingItem && File.Exists(this.EditContext?.GCodeFilePath(this.Printer))) { UiThread.RunOnIdle(async () => diff --git a/MatterControlLib/ApplicationView/PrinterViewState.cs b/MatterControlLib/ApplicationView/PrinterViewState.cs index 46de0530d..1a9f8af86 100644 --- a/MatterControlLib/ApplicationView/PrinterViewState.cs +++ b/MatterControlLib/ApplicationView/PrinterViewState.cs @@ -185,5 +185,7 @@ namespace MatterHackers.MatterControl UserSettings.Instance.set(UserSettingsKey.SelectedObjectPanelWidth, minimumValue.ToString()); } } + + public bool SlicingItem { get; set; } } } \ No newline at end of file