From: Ingo Ruhnke Date: Sun, 3 Aug 2014 17:46:20 +0000 (+0200) Subject: Fixed some std::unique_ptr<> issues X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=cbcd10c84ecd99c06e896ccab0218b1c9019ad27;p=supertux.git Fixed some std::unique_ptr<> issues --- diff --git a/src/object/player.cpp b/src/object/player.cpp index 2e2ea2840..46c4423ff 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -112,7 +112,7 @@ bool no_water = true; Player::Player(PlayerStatus* _player_status, const std::string& name) : deactivated(), controller(), - scripting_controller(0), + scripting_controller(), player_status(_player_status), duck(), dead(), diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index b33d2cc38..c81b11755 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -45,7 +45,7 @@ #include "worldmap/worldmap.hpp" GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_status, Statistics* statistics) : - level(0), + level(), statistics_backdrop(), scripts(), currentsector(0), diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index e39e24bc6..604d91f44 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -29,6 +29,7 @@ extern "C" { } #include "video/renderer.hpp" +#include "video/lightmap.hpp" #include "supertux/main.hpp" #include "addon/addon_manager.hpp" diff --git a/src/video/video_systems.cpp b/src/video/video_systems.cpp index d2810234b..1e37dd23c 100644 --- a/src/video/video_systems.cpp +++ b/src/video/video_systems.cpp @@ -33,7 +33,7 @@ #include "video/gl/gl_texture.hpp" #endif -Renderer* +std::unique_ptr VideoSystem::new_renderer() { switch(g_config->video) @@ -42,56 +42,56 @@ VideoSystem::new_renderer() #ifdef HAVE_OPENGL try { log_info << "new GL renderer\n"; - return new GLRenderer(); + return std::unique_ptr(new GLRenderer()); } catch(std::runtime_error& e) { log_warning << "Error creating GL renderer: " << e.what() << std::endl; #endif log_warning << "new SDL renderer\n"; - return new SDLRenderer(); + return std::unique_ptr(new SDLRenderer()); #ifdef HAVE_OPENGL } case OPENGL: log_info << "new GL renderer\n"; - return new GLRenderer(); + return std::unique_ptr(new GLRenderer()); #endif case PURE_SDL: log_info << "new SDL renderer\n"; - return new SDLRenderer(); + return std::unique_ptr(new SDLRenderer()); default: assert(0 && "invalid video system in config"); #ifdef HAVE_OPENGL log_info << "new GL renderer\n"; - return new GLRenderer(); + return std::unique_ptr(new GLRenderer()); #else log_warning << "new SDL renderer\n"; - return new SDLRenderer(); + return std::unique_ptr(new SDLRenderer()); #endif } } -Lightmap* +std::unique_ptr VideoSystem::new_lightmap() { switch(g_config->video) { case AUTO_VIDEO: #ifdef HAVE_OPENGL - return new GLLightmap(); + return std::unique_ptr(new GLLightmap()); #else - return new SDLLightmap(); + return std::unique_ptr(new SDLLightmap()); #endif #ifdef HAVE_OPENGL case OPENGL: - return new GLLightmap(); + return std::unique_ptr(new GLLightmap()); #endif case PURE_SDL: - return new SDLLightmap(); + return std::unique_ptr(new SDLLightmap()); default: assert(0 && "invalid video system in config"); #ifdef HAVE_OPENGL - return new GLLightmap(); + return std::unique_ptr(new GLLightmap()); #else - return new SDLLightmap(); + return std::unique_ptr(new SDLLightmap()); #endif } } diff --git a/src/video/video_systems.hpp b/src/video/video_systems.hpp index e82ceda49..f65d7bfd6 100644 --- a/src/video/video_systems.hpp +++ b/src/video/video_systems.hpp @@ -40,8 +40,8 @@ public: }; public: - static Renderer* new_renderer(); - static Lightmap* new_lightmap(); + static std::unique_ptr new_renderer(); + static std::unique_ptr new_lightmap(); static TexturePtr new_texture(SDL_Surface *image); static SurfaceData* new_surface_data(const Surface &surface); static void free_surface_data(SurfaceData* surface_data);