]> git.mxchange.org Git - flightgear.git/commitdiff
Fix canvas clean up.
authorThomas Geymayer <tomgey@gmail.com>
Tue, 3 Jul 2012 14:29:37 +0000 (16:29 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Tue, 3 Jul 2012 14:29:44 +0000 (16:29 +0200)
On clean up there are no parents any more and therefore the assertion
was triggered.

src/Canvas/canvas.cxx

index f1a6ef983e4d8a64c5539a773faead9f9a7e3b73..7f2c8590296ccd1883ea5d7db38a6045ae0c4918 100644 (file)
@@ -434,15 +434,17 @@ void Canvas::clearPlacements(int index)
     osg::ref_ptr<osg::Group> group = placements.back();
     placements.pop_back();
 
-    assert( group->getNumParents() == 1 );
     assert( group->getNumChildren() == 1 );
-
-    osg::Group *parent = group->getParent(0);
     osg::Node *child = group->getChild(0);
 
-    parent->addChild(child);
+    if( group->getNumParents() )
+    {
+      osg::Group *parent = group->getParent(0);
+      parent->addChild(child);
+      parent->removeChild(group);
+    }
+
     group->removeChild(child);
-    parent->removeChild(group);
   }
 }