From: Thomas Geymayer Date: Tue, 1 Jul 2014 10:09:55 +0000 (+0200) Subject: canvas::Element: fix cleanup (and hopefully crash) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6200b160ec0252060bcfb13f65076490af315c6d;p=simgear.git canvas::Element: fix cleanup (and hopefully crash) --- diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index 98f93343..16b02c26 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -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; } //---------------------------------------------------------------------------- diff --git a/simgear/props/PropertyBasedElement.cxx b/simgear/props/PropertyBasedElement.cxx index 348842b9..f9f7fb27 100644 --- a/simgear/props/PropertyBasedElement.cxx +++ b/simgear/props/PropertyBasedElement.cxx @@ -39,7 +39,8 @@ namespace simgear //---------------------------------------------------------------------------- void PropertyBasedElement::removeListener() { - _node->removeChangeListener(this); + if( _node ) + _node->removeChangeListener(this); } //----------------------------------------------------------------------------