From 10600e94f9b5aa57586c0e51a1b8a33c7fece07e Mon Sep 17 00:00:00 2001 From: unitraxx Date: Fri, 16 Aug 2013 01:19:12 +0000 Subject: [PATCH] Memory management in friends fetching back ok. Something weird happened with my commit this morning. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13488 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/online/profile.cpp | 9 ++------- src/online/profile.hpp | 7 ++----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/online/profile.cpp b/src/online/profile.cpp index c0ff2754d..e7950c915 100644 --- a/src/online/profile.cpp +++ b/src/online/profile.cpp @@ -46,8 +46,6 @@ namespace Online{ m_is_current_user = (m_id == CurrentUser::get()->getUserID()); m_has_fetched_friends = false; - m_friends_list_request = NULL; - } // ============================================================================ @@ -57,7 +55,7 @@ namespace Online{ if(m_has_fetched_friends) return; setState (S_FETCHING); - m_friends_list_request = requestFriendsList(); + requestFriendsList(); } // ============================================================================ @@ -75,15 +73,13 @@ namespace Online{ m_friends.push_back(new User(username, friendid)); } m_has_fetched_friends = true; - delete m_friends_list_request; - m_friends_list_request = NULL; Profile::setState (Profile::S_READY); } // ============================================================================ - const Profile::FriendsListRequest * Profile::requestFriendsList() + void Profile::requestFriendsList() { FriendsListRequest * request = new FriendsListRequest(); request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php"); @@ -92,7 +88,6 @@ namespace Online{ request->setParameter("userid", CurrentUser::get()->getUserID()); request->setParameter("visitingid", m_id); HTTPManager::get()->addRequest(request); - return request; } void Profile::FriendsListRequest::callback() diff --git a/src/online/profile.hpp b/src/online/profile.hpp index 0a3f6b539..be98419b2 100644 --- a/src/online/profile.hpp +++ b/src/online/profile.hpp @@ -45,7 +45,7 @@ namespace Online{ { virtual void callback (); public: - FriendsListRequest() : XMLRequest() {} + FriendsListRequest() : XMLRequest(0, true) {} }; private: @@ -62,16 +62,13 @@ namespace Online{ bool m_has_fetched_friends; PtrVector m_friends; - const FriendsListRequest * m_friends_list_request; bool m_cache_bit; - - void setState(State state) { m_state.setAtomic(state); } const State getState() const { return m_state.getAtomic(); } - const FriendsListRequest * requestFriendsList(); + void requestFriendsList(); void friendsListCallback(const XMLNode * input); public: