forked from mirrors/0ad
Use unique_ptr for glox::Tag in XmppClient
This commit is contained in:
@@ -211,13 +211,6 @@ XmppClient::~XmppClient()
|
|||||||
m_client->removePresenceExtension(gloox::ExtCaps);
|
m_client->removePresenceExtension(gloox::ExtCaps);
|
||||||
|
|
||||||
delete m_client;
|
delete m_client;
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : m_GameList)
|
|
||||||
delete t;
|
|
||||||
for (const gloox::Tag* const& t : m_BoardList)
|
|
||||||
delete t;
|
|
||||||
for (const gloox::Tag* const& t : m_Profile)
|
|
||||||
delete t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Network
|
/// Network
|
||||||
@@ -280,18 +273,12 @@ void XmppClient::onDisconnect(gloox::ConnectionError error)
|
|||||||
m_mucRoom->leave();
|
m_mucRoom->leave();
|
||||||
|
|
||||||
// Clear game, board and player lists.
|
// Clear game, board and player lists.
|
||||||
for (const gloox::Tag* const& t : m_GameList)
|
|
||||||
delete t;
|
|
||||||
for (const gloox::Tag* const& t : m_BoardList)
|
|
||||||
delete t;
|
|
||||||
for (const gloox::Tag* const& t : m_Profile)
|
|
||||||
delete t;
|
|
||||||
|
|
||||||
m_BoardList.clear();
|
|
||||||
m_GameList.clear();
|
m_GameList.clear();
|
||||||
|
m_BoardList.clear();
|
||||||
|
m_Profile.clear();
|
||||||
|
|
||||||
m_PlayerMap.clear();
|
m_PlayerMap.clear();
|
||||||
m_PlayerMapUpdate = true;
|
m_PlayerMapUpdate = true;
|
||||||
m_Profile.clear();
|
|
||||||
m_HistoricGuiMessages.clear();
|
m_HistoricGuiMessages.clear();
|
||||||
m_initialLoadComplete = false;
|
m_initialLoadComplete = false;
|
||||||
|
|
||||||
@@ -619,7 +606,7 @@ JS::Value XmppClient::GUIGetGameList(const ScriptRequest& rq)
|
|||||||
"nbp", "maxnbp", "players", "mapName", "niceMapName", "mapSize", "mapType",
|
"nbp", "maxnbp", "players", "mapName", "niceMapName", "mapSize", "mapType",
|
||||||
"victoryConditions", "startTime", "mods" };
|
"victoryConditions", "startTime", "mods" };
|
||||||
|
|
||||||
for(const gloox::Tag* const& t : m_GameList)
|
for(const std::unique_ptr<const gloox::Tag>& t : m_GameList)
|
||||||
{
|
{
|
||||||
JS::RootedValue game(rq.cx);
|
JS::RootedValue game(rq.cx);
|
||||||
Script::CreateObject(rq, &game);
|
Script::CreateObject(rq, &game);
|
||||||
@@ -644,7 +631,7 @@ JS::Value XmppClient::GUIGetBoardList(const ScriptRequest& rq)
|
|||||||
|
|
||||||
const char* attributes[] = { "name", "rank", "rating" };
|
const char* attributes[] = { "name", "rank", "rating" };
|
||||||
|
|
||||||
for(const gloox::Tag* const& t : m_BoardList)
|
for(const std::unique_ptr<const gloox::Tag>& t : m_BoardList)
|
||||||
{
|
{
|
||||||
JS::RootedValue board(rq.cx);
|
JS::RootedValue board(rq.cx);
|
||||||
Script::CreateObject(rq, &board);
|
Script::CreateObject(rq, &board);
|
||||||
@@ -669,7 +656,7 @@ JS::Value XmppClient::GUIGetProfile(const ScriptRequest& rq)
|
|||||||
|
|
||||||
const char* stats[] = { "player", "rating", "totalGamesPlayed", "highestRating", "wins", "losses", "rank" };
|
const char* stats[] = { "player", "rating", "totalGamesPlayed", "highestRating", "wins", "losses", "rank" };
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : m_Profile)
|
for (const std::unique_ptr<const gloox::Tag>& t : m_Profile)
|
||||||
{
|
{
|
||||||
JS::RootedValue profile(rq.cx);
|
JS::RootedValue profile(rq.cx);
|
||||||
Script::CreateObject(rq, &profile);
|
Script::CreateObject(rq, &profile);
|
||||||
@@ -887,8 +874,6 @@ bool XmppClient::handleIq(const gloox::IQ& iq)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : m_GameList)
|
|
||||||
delete t;
|
|
||||||
m_GameList.clear();
|
m_GameList.clear();
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : gq->m_GameList)
|
for (const gloox::Tag* const& t : gq->m_GameList)
|
||||||
@@ -906,8 +891,6 @@ bool XmppClient::handleIq(const gloox::IQ& iq)
|
|||||||
|
|
||||||
if (bq->m_Command == "boardlist")
|
if (bq->m_Command == "boardlist")
|
||||||
{
|
{
|
||||||
for (const gloox::Tag* const& t : m_BoardList)
|
|
||||||
delete t;
|
|
||||||
m_BoardList.clear();
|
m_BoardList.clear();
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : bq->m_StanzaBoardList)
|
for (const gloox::Tag* const& t : bq->m_StanzaBoardList)
|
||||||
@@ -937,8 +920,6 @@ bool XmppClient::handleIq(const gloox::IQ& iq)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : m_Profile)
|
|
||||||
delete t;
|
|
||||||
m_Profile.clear();
|
m_Profile.clear();
|
||||||
|
|
||||||
for (const gloox::Tag* const& t : pq->m_StanzaProfile)
|
for (const gloox::Tag* const& t : pq->m_StanzaProfile)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <js/Vector.h>
|
#include <js/Vector.h>
|
||||||
#include <js/GCVector.h>
|
#include <js/GCVector.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -181,11 +182,11 @@ private:
|
|||||||
/// Whether or not the playermap has changed since the last time the GUI checked.
|
/// Whether or not the playermap has changed since the last time the GUI checked.
|
||||||
bool m_PlayerMapUpdate;
|
bool m_PlayerMapUpdate;
|
||||||
/// List of games
|
/// List of games
|
||||||
std::vector<const gloox::Tag*> m_GameList;
|
std::vector<std::unique_ptr<const gloox::Tag>> m_GameList;
|
||||||
/// List of rankings
|
/// List of rankings
|
||||||
std::vector<const gloox::Tag*> m_BoardList;
|
std::vector<std::unique_ptr<const gloox::Tag>> m_BoardList;
|
||||||
/// Profile data
|
/// Profile data
|
||||||
std::vector<const gloox::Tag*> m_Profile;
|
std::vector<std::unique_ptr<const gloox::Tag>> m_Profile;
|
||||||
/// ScriptInterface to root the values
|
/// ScriptInterface to root the values
|
||||||
const ScriptInterface* m_ScriptInterface;
|
const ScriptInterface* m_ScriptInterface;
|
||||||
/// Queue of messages for the GUI
|
/// Queue of messages for the GUI
|
||||||
|
|||||||
Reference in New Issue
Block a user