mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-09 14:52:28 -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();
|
||||||
|
@ -355,7 +359,6 @@ 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;
|
||||||
|
@ -363,6 +366,7 @@ bool p3MsgService::loadList(std::list<RsItem*> load)
|
||||||
|
|
||||||
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,9 +381,20 @@ 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)))
|
||||||
|
{
|
||||||
|
// 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));
|
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)))
|
||||||
{
|
{
|
||||||
mMsgTags.insert(std::pair<uint32_t, RsMsgTags* >(mti->msgId, mti));
|
mMsgTags.insert(std::pair<uint32_t, RsMsgTags* >(mti->msgId, mti));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue