]> git.mxchange.org Git - simgear.git/commitdiff
canvas::Element: fix cleanup (and hopefully crash)
authorThomas Geymayer <tomgey@gmail.com>
Tue, 1 Jul 2014 10:09:55 +0000 (12:09 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Tue, 1 Jul 2014 10:09:55 +0000 (12:09 +0200)
simgear/canvas/elements/CanvasElement.cxx
simgear/props/PropertyBasedElement.cxx

index 98f93343bc2c1858fd419751c3ef748662fdf0e5..16b02c26cc77d5e27f45d67c5b5db8df244dec70 100644 (file)
@@ -202,6 +202,13 @@ namespace canvas
     {
       parent->removeChild(_transform.get());
     }
+
+    // Hide in case someone still holds a reference
+    setVisible(false);
+    removeListener();
+
+    _parent = 0;
+    _transform = 0;
   }
 
   //----------------------------------------------------------------------------
index 348842b9142342eb979286eb03ab1d4755cb33b9..f9f7fb278042a726dedf7dd390c664f0f5759a2a 100644 (file)
@@ -39,7 +39,8 @@ namespace simgear
   //----------------------------------------------------------------------------
   void PropertyBasedElement::removeListener()
   {
-    _node->removeChangeListener(this);
+    if( _node )
+      _node->removeChangeListener(this);
   }
 
   //----------------------------------------------------------------------------