From 0163cf6849280eb9d25de5420f1ef4f95f14e9ff Mon Sep 17 00:00:00 2001 From: jlewin Date: Fri, 22 Mar 2019 11:58:00 -0700 Subject: [PATCH] Dispose previous wizard when switching between stages - Issue MatterHackers/MCCentral#5202 SetupWizards should be modified to undo their changes if aborted/ cancelled --- MatterControlLib/SetupWizard/StagedSetupWindow.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MatterControlLib/SetupWizard/StagedSetupWindow.cs b/MatterControlLib/SetupWizard/StagedSetupWindow.cs index 1ca236028..b56c1e7e2 100644 --- a/MatterControlLib/SetupWizard/StagedSetupWindow.cs +++ b/MatterControlLib/SetupWizard/StagedSetupWindow.cs @@ -56,9 +56,13 @@ namespace MatterHackers.MatterControl if (_activeStage != null && stageButtons.TryGetValue(_activeStage, out WizardStageRow activeButton)) { + // Mark the leftnav widget as inactive activeButton.Active = false; } + // Shutdown the active Wizard + _activeStage?.Dispose(); + _activeStage = value; if (stageButtons.TryGetValue(_activeStage, out WizardStageRow stageButton)) @@ -78,7 +82,6 @@ namespace MatterHackers.MatterControl this.stages = stages; this.homePageGenerator = homePageGenerator; - var activeStage = stages.First(); var theme = AppContext.Theme; var row = new FlowLayoutWidget() @@ -155,6 +158,11 @@ namespace MatterHackers.MatterControl this.ActiveStage = nextStage; return; } + else + { + // Shutdown the active wizard + this.ActiveStage?.Dispose(); + } // Move to next unfinished wizard or move to summary/home page this.ChangeToPage(homePageGenerator());