From d5c1ac30abca41749981e8a8b8ee0c54731f18e5 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 5 Mar 2018 16:34:15 +0800 Subject: [PATCH] Fix signin leaking --- src/config/player_manager.cpp | 6 +++--- src/config/player_manager.hpp | 4 ++-- src/config/player_profile.hpp | 4 ++-- src/main.cpp | 4 +--- src/online/online_player_profile.cpp | 7 ++----- src/online/online_player_profile.hpp | 6 +++--- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/config/player_manager.cpp b/src/config/player_manager.cpp index 171050be3..416600b46 100644 --- a/src/config/player_manager.cpp +++ b/src/config/player_manager.cpp @@ -129,10 +129,10 @@ void PlayerManager::onSTKQuit() * RequestManager. */ -Online::XMLRequest *PlayerManager::requestSignIn(const irr::core::stringw &username, - const irr::core::stringw &password) +void PlayerManager::requestSignIn(const irr::core::stringw &username, + const irr::core::stringw &password) { - return getCurrentPlayer()->requestSignIn(username, password); + getCurrentPlayer()->requestSignIn(username, password); } // requestSignIn // ---------------------------------------------------------------------------- diff --git a/src/config/player_manager.hpp b/src/config/player_manager.hpp index 929d55f90..e7fba9039 100644 --- a/src/config/player_manager.hpp +++ b/src/config/player_manager.hpp @@ -111,8 +111,8 @@ public: static void resumeSavedSession(); static void onSTKQuit(); static void requestSignOut(); - static Online::XMLRequest *requestSignIn(const irr::core::stringw &username, - const irr::core::stringw &password); + static void requestSignIn(const irr::core::stringw &username, + const irr::core::stringw &password); // ------------------------------------------------------------------------ /** Returns the current player. */ diff --git a/src/config/player_profile.hpp b/src/config/player_profile.hpp index 9c5cfebb0..4d7962043 100644 --- a/src/config/player_profile.hpp +++ b/src/config/player_profile.hpp @@ -138,8 +138,8 @@ public: virtual Online::OnlineProfile* getProfile() const = 0; virtual void requestPoll() const = 0; virtual void requestSavedSession() = 0; - virtual Online::XMLRequest* requestSignIn(const irr::core::stringw &username, - const irr::core::stringw &password) = 0; + virtual void requestSignIn(const irr::core::stringw &username, + const irr::core::stringw &password) = 0; virtual void signIn(bool success, const XMLNode * input) = 0; virtual void signOut(bool success, const XMLNode * input, const irr::core::stringw &info) = 0; diff --git a/src/main.cpp b/src/main.cpp index 1776bdfa7..be972329e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1023,8 +1023,7 @@ int handleCmdLine() if (!login.empty() && !password.empty()) { irr::core::stringw s; - Online::XMLRequest* request = - PlayerManager::requestSignIn(login, password); + PlayerManager::requestSignIn(login, password); while (PlayerManager::getCurrentOnlineState() != PlayerProfile::OS_SIGNED_IN) { Online::RequestManager::get()->update(0.0f); @@ -1032,7 +1031,6 @@ int handleCmdLine() } Log::info("Main", "Logged in from command-line."); can_wan = true; - delete request; } if (!can_wan && CommandLine::has("--login-id", &n) && diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp index ce9b66fc3..3ebb7bc33 100644 --- a/src/online/online_player_profile.cpp +++ b/src/online/online_player_profile.cpp @@ -111,15 +111,14 @@ namespace Online * \param username Name of user. * \param password Password. */ - OnlinePlayerProfile::SignInRequest* - OnlinePlayerProfile::requestSignIn(const core::stringw &username, + void OnlinePlayerProfile::requestSignIn(const core::stringw &username, const core::stringw &password) { // If the player changes the online account, there can be a // logout stil happening. assert(m_online_state == OS_SIGNED_OUT || m_online_state == OS_SIGNING_OUT); - SignInRequest * request = new SignInRequest(false); + SignInRequest * request = new SignInRequest(true); // We can't use setUserDetail here, since there is no token yet request->setApiURL(API::USER_PATH, "connect"); @@ -130,8 +129,6 @@ namespace Online : "false"); request->queue(); m_online_state = OS_SIGNING_IN; - - return request; } // requestSignIn // ------------------------------------------------------------------------ diff --git a/src/online/online_player_profile.hpp b/src/online/online_player_profile.hpp index 3d2982c12..318a68dcd 100644 --- a/src/online/online_player_profile.hpp +++ b/src/online/online_player_profile.hpp @@ -52,7 +52,7 @@ namespace Online { virtual void callback (); public: - SignInRequest(bool manage_memory = false) + SignInRequest(bool manage_memory) : XMLRequest(manage_memory, /*priority*/10) {} }; // SignInRequest @@ -105,8 +105,8 @@ namespace Online const std::string& getToken() const { return m_token; } virtual void requestSavedSession(); virtual void requestSignOut(); - virtual SignInRequest *requestSignIn(const irr::core::stringw &username, - const irr::core::stringw &password); + virtual void requestSignIn(const irr::core::stringw &username, + const irr::core::stringw &password); public: OnlinePlayerProfile(const XMLNode *player);