diff --git a/src/sdlf/Window.cpp b/src/sdlf/Window.cpp index 7f27c71..cd4bb50 100644 --- a/src/sdlf/Window.cpp +++ b/src/sdlf/Window.cpp @@ -22,7 +22,7 @@ namespace sf SDLF_REQUIRED_SUBSYSTEMS << " but got " << mask << " instead). \n" << "Make sure to call SDL_Init(" << SDLF_REQUIRED_SUBSYSTEMS << ") before instantiating sf::IWindow. \n" << "The most recent SDL_Error is: " << SDL_GetError() << std::endl; - m_pCurrentException = const_cast(errorStream.str().c_str()); + m_pCurrentException = errorStream.str(); return; } @@ -32,7 +32,7 @@ namespace sf m_pWindow = SDL_CreateWindow(title.c_str(), position.x, position.y, size.x, size.y, windowFlags); if (IS_NULLPTR(m_pWindow)) { - m_pCurrentException = const_cast(SDL_GetError()); + m_pCurrentException = SDL_GetError(); return; } } @@ -43,7 +43,7 @@ namespace sf m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, renderFlags); if (IS_NULLPTR(m_pRenderer)) { - m_pCurrentException = const_cast(SDL_GetError()); + m_pCurrentException = SDL_GetError(); return; } } @@ -125,7 +125,7 @@ namespace sf void IWindow::MessageLoop() { Create(m_oSize, m_oPosition, m_strTitle, m_uWindowFlags, m_uRenderFlags); - if (std::strcmp(m_pCurrentException, "")) + if (m_pCurrentException != "") { std::cerr << "ERROR: " << m_pCurrentException << std::endl; return; diff --git a/src/sdlf/Window.hpp b/src/sdlf/Window.hpp index 7921a40..feec15f 100644 --- a/src/sdlf/Window.hpp +++ b/src/sdlf/Window.hpp @@ -30,7 +30,7 @@ namespace sf void SwitchScreen(IScreen* screen); - const char* GetCurrentException() const { return m_pCurrentException; } + std::string GetCurrentException() const { return m_pCurrentException; } protected: IWindow(Vector2u size, Vector2i position, std::string title, @@ -48,7 +48,7 @@ namespace sf SDL_Event m_oEvent; std::atomic_bool m_atomWindowOpen; - char* m_pCurrentException; + std::string m_pCurrentException; private: void MessageLoop();