Skip to content

Commit

Permalink
Fixes #2967. Not all views are removing his subviews upon disposing o…
Browse files Browse the repository at this point in the history
…n both versions. (#2968)

Co-authored-by: Tig <tig@users.noreply.github.com>
  • Loading branch information
BDisp and tig authored Nov 16, 2023
1 parent 66ca7f8 commit 8cb10f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Terminal.Gui/View/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public override string ToString ()
protected override void Dispose (bool disposing)
{
LineCanvas.Dispose ();

Margin?.Dispose ();
Margin = null;
Border?.Dispose ();
Expand All @@ -513,8 +513,9 @@ protected override void Dispose (bool disposing)
Remove (subview);
subview.Dispose ();
}

base.Dispose (disposing);
System.Diagnostics.Debug.Assert (InternalSubviews.Count == 0);
}
}
}
12 changes: 8 additions & 4 deletions Terminal.Gui/Views/Wizard/WizardStep.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Terminal.Gui;
namespace Terminal.Gui;

/// <summary>
/// Represents a basic step that is displayed in a <see cref="Wizard"/>. The <see cref="WizardStep"/> view is divided horizontally in two. On the left is the
Expand Down Expand Up @@ -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" };

/// <summary>
/// Sets or gets help text for the <see cref="WizardStep"/>.If <see cref="WizardStep.HelpText"/> is empty
Expand Down Expand Up @@ -185,8 +185,12 @@ public override void Remove (View view)
}

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;
Expand Down

0 comments on commit 8cb10f8

Please sign in to comment.