From f5015d1cd695afc2e69114e10e34d05aa06ab554 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 2 Jul 2020 13:48:49 -0700 Subject: [PATCH] Make sure we don't crash if the slice is canceled and there is an error disposing it. issue: MatterHackers/MCCentral#5929 InvalidOperationException: No process is associated with this object. --- .../SlicerConfiguration/EngineMappingsMatterSlice.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs b/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs index d7a0bdfc1..00ef6aed8 100644 --- a/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs +++ b/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs @@ -452,8 +452,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { if (cancellationToken.IsCancellationRequested) { - slicerProcess?.Kill(); - slicerProcess?.Dispose(); + // If for some reason we cannot kill the slicing process do not exit + try + { + slicerProcess?.Kill(); + slicerProcess?.Dispose(); + } + catch + { + } + forcedExit = true; }