From 8cb10f8f095d8cd599783ddfc9df89ffded7f27e Mon Sep 17 00:00:00 2001 From: BDisp Date: Thu, 16 Nov 2023 14:13:43 +0000 Subject: [PATCH] Fixes #2967. Not all views are removing his subviews upon disposing on both versions. (#2968) Co-authored-by: Tig --- Terminal.Gui/View/View.cs | 5 +++-- Terminal.Gui/Views/Wizard/WizardStep.cs | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs index 0d3b360c2..66799dc50 100644 --- a/Terminal.Gui/View/View.cs +++ b/Terminal.Gui/View/View.cs @@ -495,7 +495,7 @@ namespace Terminal.Gui { protected override void Dispose (bool disposing) { LineCanvas.Dispose (); - + Margin?.Dispose (); Margin = null; Border?.Dispose (); @@ -513,8 +513,9 @@ namespace Terminal.Gui { Remove (subview); subview.Dispose (); } - + base.Dispose (disposing); + System.Diagnostics.Debug.Assert (InternalSubviews.Count == 0); } } } diff --git a/Terminal.Gui/Views/Wizard/WizardStep.cs b/Terminal.Gui/Views/Wizard/WizardStep.cs index 3efd1d5e5..6828727fd 100644 --- a/Terminal.Gui/Views/Wizard/WizardStep.cs +++ b/Terminal.Gui/Views/Wizard/WizardStep.cs @@ -1,4 +1,4 @@ -namespace Terminal.Gui; +namespace Terminal.Gui; /// /// Represents a basic step that is displayed in a . The view is divided horizontally in two. On the left is the @@ -39,7 +39,7 @@ public class WizardStep : FrameView { //private string title = string.Empty; // The contentView works like the ContentView in FrameView. - private View contentView = new View () { Data = "WizardContentView" }; + private View contentView = new View () { Id = "WizardContentView" }; /// /// Sets or gets help text for the .If is empty @@ -185,8 +185,12 @@ public class WizardStep : FrameView { } SetNeedsDisplay (); - var touched = view.Frame; - contentView.Remove (view); + var container = view?.SuperView; + if (container == this) { + base.Remove (view); + } else { + container?.Remove (view); + } if (contentView.InternalSubviews.Count < 1) { this.CanFocus = false;