From: Thomas Geymayer Date: Fri, 14 Jun 2013 17:47:09 +0000 (+0200) Subject: CanvasGroup: Do not try to remove already removed children. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e27b6d050c158f34cd7592fee895737b40ae527c;p=simgear.git CanvasGroup: Do not try to remove already removed children. --- diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index 522a2ef7..7f5ba02d 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -209,6 +209,9 @@ namespace canvas //---------------------------------------------------------------------------- bool Element::accept(EventVisitor& visitor) { + if( !_transform.valid() ) + return false; + return visitor.apply(*this); } @@ -314,6 +317,9 @@ namespace canvas { if( parent == _node && child->getNameString() == NAME_TRANSFORM ) { + if( !_transform.valid() ) + return; + if( child->getIndex() >= static_cast(_transform_types.size()) ) { SG_LOG diff --git a/simgear/canvas/elements/CanvasGroup.cxx b/simgear/canvas/elements/CanvasGroup.cxx index ff0cdd5f..f910315d 100644 --- a/simgear/canvas/elements/CanvasGroup.cxx +++ b/simgear/canvas/elements/CanvasGroup.cxx @@ -263,6 +263,11 @@ namespace canvas if( getChildFactory(node->getNameString()) ) { + if( !_transform.valid() ) + // If transform is destroyed also all children are destroyed, so we can + // not do anything here. + return; + ElementPtr child = getChild(node); if( !child ) SG_LOG @@ -348,8 +353,10 @@ namespace canvas //---------------------------------------------------------------------------- ElementPtr Group::getChildByIndex(size_t index) const { + assert(_transform.valid()); OSGUserData* ud = static_cast(_transform->getChild(index)->getUserData()); + assert(ud); return ud->element; }