From d05c6de3ef7b49aac5cdce4d50ef3b95d0c85e68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 28 Aug 2017 04:31:31 +0200 Subject: [PATCH] override dispose in popper to handle _content not yet in graphic tree (when never shown), test focusedWidget when disposing --- src/GraphicObjects/GraphicObject.cs | 6 +++++- src/GraphicObjects/Popper.cs | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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); + } } } -- 2.47.3