Use std::unique_ptr<> in ContribMenu
authorIngo Ruhnke <grumbel@gmail.com>
Fri, 8 Aug 2014 19:32:52 +0000 (21:32 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Fri, 8 Aug 2014 19:32:52 +0000 (21:32 +0200)
src/supertux/menu/contrib_menu.cpp
src/supertux/menu/contrib_menu.hpp

index 2399d9c..2139e21 100644 (file)
@@ -51,7 +51,7 @@ ContribMenu::ContribMenu() :
       if (!world->hide_from_contribs) 
       {
         add_entry(i++, world->get_title());
-        m_contrib_worlds.push_back(world.release());
+        m_contrib_worlds.push_back(std::move(world));
       }
     }
     catch(std::exception& e)
@@ -66,11 +66,6 @@ ContribMenu::ContribMenu() :
 
 ContribMenu::~ContribMenu()
 {
-  for(std::vector<World*>::iterator i = m_contrib_worlds.begin(); i != m_contrib_worlds.end(); ++i)
-  {
-    delete *i;
-  }
-  m_contrib_worlds.clear();
 }
 
 void
@@ -79,7 +74,7 @@ ContribMenu::check_menu()
   int index = check();
   if (index != -1)
   {
-    World* world = m_contrib_worlds[index];
+    World* world = m_contrib_worlds[index].get();
     
     if (!world->is_levelset) 
     {
index 649b784..aa45b95 100644 (file)
@@ -26,7 +26,7 @@ class ContribMenu : public Menu
 {
 private:
   std::unique_ptr<ContribWorldMenu> m_contrib_world_menu;
-  std::vector<World*> m_contrib_worlds;
+  std::vector<std::unique_ptr<World> > m_contrib_worlds;
 
 public:
   ContribMenu();