[Orxonox-commit 3310] r7999 - code/branches/usability/src/orxonox

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Feb 28 05:05:02 CET 2011


Author: rgrieder
Date: 2011-02-28 05:05:02 +0100 (Mon, 28 Feb 2011)
New Revision: 7999

Modified:
   code/branches/usability/src/orxonox/LevelManager.cc
Log:
Fixing leaks:
- Loading a level and then unloading it doesn't destroy the Namespace objects --> unload everything while compiling the level list
- Delete duplicate LevelInfoItems instead of dropping them

Modified: code/branches/usability/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/usability/src/orxonox/LevelManager.cc	2011-02-28 03:58:31 UTC (rev 7998)
+++ code/branches/usability/src/orxonox/LevelManager.cc	2011-02-28 04:05:02 UTC (rev 7999)
@@ -267,7 +267,7 @@
                         info = item->copy();
 
                 // We don't need the loaded stuff anymore
-                Loader::unload(&file, mask);
+                Loader::unload(&file);
 
                 if(info == NULL) 
                 {
@@ -278,9 +278,13 @@
 
                 // Warn about multiple items so that it gets fixed quickly
                 if(availableLevels_.find(info) != availableLevels_.end())
+                {
                     COUT(2) << "Warning: Multiple levels with name '" << info->getName() << "' found!" << std::endl;
-
-                this->availableLevels_.insert(info);
+                    // Delete LevelInfoItem to avoid a dangling pointer
+                    delete info;
+                }
+                else
+                    this->availableLevels_.insert(info);
             }
         }
     }




More information about the Orxonox-commit mailing list