mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-06 21:34:22 -04:00
removed memory leak caused by moving initretroshare to msgservice onstructor
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3540 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b0f0e4c380
commit
baac505c15
1 changed files with 22 additions and 7 deletions
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
const int msgservicezone = 54319;
|
const int msgservicezone = 54319;
|
||||||
|
|
||||||
|
@ -274,12 +275,15 @@ int p3MsgService::checkOutgoingMessages()
|
||||||
std::list<RsItem*> p3MsgService::saveList(bool& cleanup)
|
std::list<RsItem*> p3MsgService::saveList(bool& cleanup)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
std::list<RsItem*> itemList;
|
std::list<RsItem*> itemList;
|
||||||
|
|
||||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||||
std::map<uint32_t, RsMsgTagType* >::iterator mit2;
|
std::map<uint32_t, RsMsgTagType* >::iterator mit2;
|
||||||
std::map<uint32_t, RsMsgTags* >::iterator mit3;
|
std::map<uint32_t, RsMsgTags* >::iterator mit3;
|
||||||
|
|
||||||
|
MsgTagType stdTags;
|
||||||
|
|
||||||
cleanup = false;
|
cleanup = false;
|
||||||
|
|
||||||
mMsgMtx.lock();
|
mMsgMtx.lock();
|
||||||
|
@ -290,8 +294,8 @@ std::list<RsItem*> p3MsgService::saveList(bool& cleanup)
|
||||||
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++)
|
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++)
|
||||||
itemList.push_back(mit->second) ;
|
itemList.push_back(mit->second) ;
|
||||||
|
|
||||||
for(mit2 = mTags.begin(); mit2 != mTags.end(); mit2++)
|
for(mit2 = mTags.begin(); mit2 != mTags.end(); mit2++)
|
||||||
itemList.push_back(mit2->second);
|
itemList.push_back(mit2->second);
|
||||||
|
|
||||||
for(mit3 = mMsgTags.begin(); mit3 != mMsgTags.end(); mit3++)
|
for(mit3 = mMsgTags.begin(); mit3 != mMsgTags.end(); mit3++)
|
||||||
itemList.push_back(mit3->second);
|
itemList.push_back(mit3->second);
|
||||||
|
@ -355,14 +359,14 @@ void p3MsgService::initStandardTagTypes()
|
||||||
|
|
||||||
bool p3MsgService::loadList(std::list<RsItem*> load)
|
bool p3MsgService::loadList(std::list<RsItem*> load)
|
||||||
{
|
{
|
||||||
|
|
||||||
RsMsgItem *mitem;
|
RsMsgItem *mitem;
|
||||||
RsMsgTagType* mtt;
|
RsMsgTagType* mtt;
|
||||||
RsMsgTags* mti;
|
RsMsgTags* mti;
|
||||||
|
|
||||||
|
|
||||||
std::list<RsMsgItem*> items;
|
std::list<RsMsgItem*> items;
|
||||||
std::list<RsItem*>::iterator it;
|
std::list<RsItem*>::iterator it;
|
||||||
|
std::map<uint32_t, RsMsgTagType*>::iterator tagIt;
|
||||||
|
|
||||||
// load items and calculate next unique msgId
|
// load items and calculate next unique msgId
|
||||||
for(it = load.begin(); it != load.end(); it++)
|
for(it = load.begin(); it != load.end(); it++)
|
||||||
|
@ -377,8 +381,19 @@ bool p3MsgService::loadList(std::list<RsItem*> load)
|
||||||
items.push_back(mitem);
|
items.push_back(mitem);
|
||||||
}
|
}
|
||||||
else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it)))
|
else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it)))
|
||||||
{
|
{
|
||||||
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
// delete standard tags as they are now save in config
|
||||||
|
if(mTags.end() == (tagIt = mTags.find(mtt->tagId)))
|
||||||
|
{
|
||||||
|
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete mTags[mtt->tagId];
|
||||||
|
mTags.erase(tagIt);
|
||||||
|
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(NULL != (mti = dynamic_cast<RsMsgTags *>(*it)))
|
else if(NULL != (mti = dynamic_cast<RsMsgTags *>(*it)))
|
||||||
{
|
{
|
||||||
|
@ -1003,7 +1018,7 @@ bool p3MsgService::setMessageTag(std::string &msgId, uint32_t tagId, bool set)
|
||||||
bool p3MsgService::resetMessageStandardTagTypes(MsgTagType& tags)
|
bool p3MsgService::resetMessageStandardTagTypes(MsgTagType& tags)
|
||||||
{
|
{
|
||||||
MsgTagType standardTags;
|
MsgTagType standardTags;
|
||||||
getStandardTagTypes(standardTags);
|
getStandardTagTypes(standardTags);
|
||||||
|
|
||||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator mit;
|
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator mit;
|
||||||
for (mit = standardTags.types.begin(); mit != standardTags.types.end(); mit++) {
|
for (mit = standardTags.types.begin(); mit != standardTags.types.end(); mit++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue