]> git.mxchange.org Git - simgear.git/commitdiff
CanvasGroup: Do not try to remove already removed children.
authorThomas Geymayer <tomgey@gmail.com>
Fri, 14 Jun 2013 17:47:09 +0000 (19:47 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Fri, 14 Jun 2013 17:47:09 +0000 (19:47 +0200)
simgear/canvas/elements/CanvasElement.cxx
simgear/canvas/elements/CanvasGroup.cxx

index 522a2ef7bd0d5ff33e7ff74d089b41f8d4011249..7f5ba02d037f18ee7be5c788a53ae560ce91bfe8 100644 (file)
@@ -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<int>(_transform_types.size()) )
       {
         SG_LOG
index ff0cdd5f70abc97e6910e7dc025ec1bfa530e0c2..f910315deca4f9d5c67961b0c946ca21506e2c2e 100644 (file)
@@ -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<OSGUserData*>(_transform->getChild(index)->getUserData());
+    assert(ud);
     return ud->element;
   }