]> O.S.I.I.S - jp/crow.git/commitdiff
override dispose in popper to handle _content not yet in graphic tree (when never...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 28 Aug 2017 02:31:31 +0000 (04:31 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 28 Aug 2017 02:31:31 +0000 (04:31 +0200)
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Popper.cs

index 624d986033b74bb192358bff4092152c847e8019..93e812def3461c4e9681b59d9c4028ed6e507aae 100644 (file)
@@ -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;
index 3ba6d71195f1f5b34b48721fdec618f1a6415a06..d6e363469fa5b0390ebbc94feb7b3e448984e39c 100644 (file)
@@ -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);
+               }
        }
 }