Browse Source

cmExportSetMap: Override clear() to delete held resources

Replace the std::map<>::clear() method with one that first deletes
the cmExportSet instances held by each map entry, and then clears.
Otherwise the cmGlobalGenerator::ClearGeneratorMembers added by
commit 5cf1120f (cmGlobalGenerator: Refactor member cleanup between
configures, 2013-11-04) leaks the cmExportSet instances.
Brad King 12 years ago
parent
commit
00055ce76d
2 changed files with 10 additions and 1 deletions
  1. 7 1
      Source/cmExportSetMap.cxx
  2. 3 0
      Source/cmExportSetMap.h

+ 7 - 1
Source/cmExportSetMap.cxx

@@ -23,7 +23,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name)
   return it->second;
 }
 
-cmExportSetMap::~cmExportSetMap()
+void cmExportSetMap::clear()
 {
   for(std::map<std::string, cmExportSet*>::iterator it = this->begin();
       it != this->end();
@@ -31,4 +31,10 @@ cmExportSetMap::~cmExportSetMap()
     {
     delete it->second;
     }
+  this->derived::clear();
+}
+
+cmExportSetMap::~cmExportSetMap()
+{
+  this->clear();
 }

+ 3 - 0
Source/cmExportSetMap.h

@@ -18,6 +18,7 @@ class cmExportSet;
 /// A name -> cmExportSet map with overloaded operator[].
 class cmExportSetMap : public std::map<std::string, cmExportSet*>
 {
+  typedef std::map<std::string, cmExportSet*> derived;
 public:
   /** \brief Overloaded operator[].
    *
@@ -26,6 +27,8 @@ public:
    */
   cmExportSet* operator[](const std::string &name);
 
+  void clear();
+
   /// Overloaded destructor deletes all member export sets.
   ~cmExportSetMap();
 };