]> git.mxchange.org Git - simgear.git/commitdiff
Another update, the previous one could crash if you leave the surrounding tiles ...
authorehofman <ehofman>
Tue, 5 Jul 2005 18:53:16 +0000 (18:53 +0000)
committerehofman <ehofman>
Tue, 5 Jul 2005 18:53:16 +0000 (18:53 +0000)
simgear/scene/model/shadowvolume.cxx

index ed1b85a84055b717928a688b5fef706e5d86b9b5..844ddddb45f3533259a37aac59d4284d75e34160 100644 (file)
@@ -786,10 +786,10 @@ SGShadowVolume::SGShadowVolume() :
 
 SGShadowVolume::~SGShadowVolume() {
        SceneryObject_map::iterator iSceneryObject;
-       for(iSceneryObject = sceneryObjects.begin() ; iSceneryObject != sceneryObjects.end();  ) {
+       for(iSceneryObject = sceneryObjects.begin() ; iSceneryObject != sceneryObjects.end(); iSceneryObject++ ) {
                delete iSceneryObject->second;
-               sceneryObjects.erase( iSceneryObject );
        }
+       sceneryObjects.clear();
 }
 
 void SGShadowVolume::init(SGPropertyNode *sim_rendering_options) {
@@ -815,14 +815,15 @@ void SGShadowVolume::init(SGPropertyNode *sim_rendering_options) {
 void SGShadowVolume::startOfFrame(void) {
 }
 void SGShadowVolume::deleteOccluderFromTile(ssgBranch *tile) {
-       SceneryObject_map::iterator iSceneryObject;
-       for(iSceneryObject = sceneryObjects.begin() ; iSceneryObject != sceneryObjects.end();  ) {
+       SceneryObject_map::iterator iSceneryObject, iPrevious;
+       iPrevious = sceneryObjects.begin();
+       for(iSceneryObject = sceneryObjects.begin() ; iSceneryObject != sceneryObjects.end(); iSceneryObject++ ) {
                if( iSceneryObject->second->tile == tile ) {
                        delete iSceneryObject->second;
                        sceneryObjects.erase( iSceneryObject );
+                       iSceneryObject = iPrevious;
                }
-               else 
-                       iSceneryObject++;
+               iPrevious = iSceneryObject;
        }
 }