From: Ingo Ruhnke Date: Fri, 8 Aug 2014 19:32:52 +0000 (+0200) Subject: Use std::unique_ptr<> in ContribMenu X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3370e84afe7f0cf18dc6bbdd6e6b9fdd0f98a05f;p=supertux.git Use std::unique_ptr<> in ContribMenu --- diff --git a/src/supertux/menu/contrib_menu.cpp b/src/supertux/menu/contrib_menu.cpp index 2399d9c9e..2139e21fd 100644 --- a/src/supertux/menu/contrib_menu.cpp +++ b/src/supertux/menu/contrib_menu.cpp @@ -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::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) { diff --git a/src/supertux/menu/contrib_menu.hpp b/src/supertux/menu/contrib_menu.hpp index 649b7847a..aa45b959f 100644 --- a/src/supertux/menu/contrib_menu.hpp +++ b/src/supertux/menu/contrib_menu.hpp @@ -26,7 +26,7 @@ class ContribMenu : public Menu { private: std::unique_ptr m_contrib_world_menu; - std::vector m_contrib_worlds; + std::vector > m_contrib_worlds; public: ContribMenu();