canvas::Element: fix cleanup (and hopefully crash)

This commit is contained in:
Thomas Geymayer 2014-07-01 12:09:55 +02:00
parent 9868fb03a2
commit 6200b160ec
2 changed files with 9 additions and 1 deletions

View 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;
}
//----------------------------------------------------------------------------

View File

@ -39,7 +39,8 @@ namespace simgear
//----------------------------------------------------------------------------
void PropertyBasedElement::removeListener()
{
_node->removeChangeListener(this);
if( _node )
_node->removeChangeListener(this);
}
//----------------------------------------------------------------------------