]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/tileentry.cxx
Remove ssg kids in a an attepmpt to fix one memory leak. We think the
[flightgear.git] / src / Scenery / tileentry.cxx
index 5633e2f7b65f9da9cbd9e5fbce917f18b51ef8c3..7df08fa7419ac65823f980a1567b3f314edd9214 100644 (file)
@@ -64,33 +64,34 @@ FGTileEntry::~FGTileEntry ( void ) {
 void
 FGTileEntry::free_tile()
 {
-    FG_LOG( FG_TERRAIN, FG_INFO,
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
            "FREEING TILE = (" << tile_bucket << ")" );
 
     // mark tile unused
     mark_unused();
 
-    // delete fragment list
-    FG_LOG( FG_TERRAIN, FG_INFO,
+    // delete fragment list and node list
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
            "  deleting " << fragment_list.size() << " fragments" );
-    // for_each( begin(), end(),
-    //           mem_fun_ref( &fgFRAGMENT::deleteDisplayList ));
-    fragment_list.erase( begin(), end() );
+    fragment_list.clear();
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
+           "  deleting " << nodes.size() << " nodes" );
+    nodes.clear();
 
-    // delete the ssg used structures
-    FG_LOG( FG_TERRAIN, FG_INFO,
+    // delete the ssg structures
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
            "  deleting vertex, normal, and texture coordinate arrays" );
-    FG_LOG( FG_TERRAIN, FG_INFO,
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
            "    deleting vertex array" );
     if ( vtlist != NULL ) {
        delete vtlist;
     }
-    FG_LOG( FG_TERRAIN, FG_INFO,
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
            "    deleting normal array" );
     if ( vnlist != NULL ) {
        delete vnlist;
     }
-    FG_LOG( FG_TERRAIN, FG_INFO,
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
            "    deleting texture coordinate array" );
     if ( tclist != NULL ) {
        delete tclist;
@@ -110,9 +111,10 @@ FGTileEntry::free_tile()
        for ( int i = 0; i < kcount; ++i ) {
            ssgEntity *kid = parent->getKid( i );
            if ( kid == select_ptr ) {
-               FG_LOG( FG_TERRAIN, FG_INFO,
+               FG_LOG( FG_TERRAIN, FG_DEBUG,
                        "Found a kid to delete " << kid);
                found_kid = true;
+               parent->removeKid( i );
            }
        }
        if ( ! found_kid ) {
@@ -133,19 +135,19 @@ FGTileEntry::free_tile()
 // selector to disable it from ever being drawn.
 void 
 FGTileEntry::ssg_disable() {
-    cout << "TILE STATE = " << state << endl;
+    // cout << "TILE STATE = " << state << endl;
     if ( state == Scheduled_for_use ) {
        state = Scheduled_for_cache;
     } else if ( state == Scheduled_for_cache ) {
        // do nothing
     } else if ( (state == Loaded) || (state == Cached) ) {
        state = Cached;
-       cout << "DISABLING SSG NODE" << endl;
+       // cout << "DISABLING SSG NODE" << endl;
        select_ptr->select(0);
     } else {
        FG_LOG( FG_TERRAIN, FG_ALERT,
                "Trying to disable an unused tile!  Dying" );
        exit(-1);
     }  
-    cout << "TILE STATE = " << state << endl;
+    // cout << "TILE STATE = " << state << endl;
 }