From: Jean-Philippe Bruyère Date: Mon, 28 Aug 2017 02:31:31 +0000 (+0200) Subject: override dispose in popper to handle _content not yet in graphic tree (when never... X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=d05c6de3ef7b49aac5cdce4d50ef3b95d0c85e68;p=jp%2Fcrow.git override dispose in popper to handle _content not yet in graphic tree (when never shown), test focusedWidget when disposing --- diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 624d9860..93e812de 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -62,7 +62,7 @@ namespace Crow #if DEBUG_DISPOSE Debug.WriteLine ("Disposing: {0}", this.ToString()); if (IsQueueForRedraw) - throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString()); + throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString()); #endif if (currentInterface.HoverWidget != null) { if (currentInterface.HoverWidget.IsOrIsInside(this)) @@ -72,6 +72,10 @@ namespace Crow if (currentInterface.ActiveWidget.IsOrIsInside (this)) currentInterface.ActiveWidget = null; } + if (currentInterface.FocusedWidget != null) { + if (currentInterface.FocusedWidget.IsOrIsInside (this)) + currentInterface.FocusedWidget = null; + } if (!localDataSourceIsNull) DataSource = null; parent = null; diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 3ba6d711..d6e36346 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -240,5 +240,14 @@ namespace Crow } Unpoped.Raise (this, e); } + + protected override void Dispose (bool disposing) + { + if (_content != null && disposing) { + if (_content.Parent == null) + _content.Dispose (); + } + base.Dispose (disposing); + } } }