fix a bug when removing friends

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2050 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-15 19:43:00 +00:00
parent 0d06dbe55b
commit 0318e73917

View File

@ -2143,34 +2143,45 @@ bool p3ConnectMgr::removeFriend(std::string id)
/* move to othersList */ /* move to othersList */
bool success = false; bool success = false;
std::list<std::string> toRemove;
std::map<std::string, peerConnectState>::iterator it; std::map<std::string, peerConnectState>::iterator it;
if (mFriendList.end() != (it = mFriendList.find(id))) //remove ssl and gpg_ids
{ for(it = mFriendList.begin(); it != mFriendList.end(); it++)
{
if (it->second.id == id || it->second.gpg_id == id) {
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::removeFriend() friend found in the list." << id << std::endl; std::cerr << "p3ConnectMgr::removeFriend() friend found in the list." << id << std::endl;
#endif #endif
peerConnectState peer = it->second; peerConnectState peer = it->second;
mFriendList.erase(it); toRemove.push_back(it->second.id);
peer.state &= (~RS_PEER_S_FRIEND); peer.state &= (~RS_PEER_S_FRIEND);
peer.state &= (~RS_PEER_S_CONNECTED); peer.state &= (~RS_PEER_S_CONNECTED);
peer.state &= (~RS_PEER_S_ONLINE); peer.state &= (~RS_PEER_S_ONLINE);
peer.actions = RS_PEER_MOVED; peer.actions = RS_PEER_MOVED;
peer.inConnAttempt = false; peer.inConnAttempt = false;
//mOthersList[id] = peer; mOthersList[id] = peer;
mStatusChanged = true; mStatusChanged = true;
success = true; success = true;
}
} }
std::list<std::string>::iterator toRemoveIt;
for(toRemoveIt = toRemove.begin(); toRemoveIt != toRemove.end(); toRemoveIt++) {
if (mFriendList.end() != (it = mFriendList.find(*toRemoveIt))) {
mFriendList.erase(it);
}
}
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl; std::cerr << "p3ConnectMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
#endif #endif
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return success; return !toRemove.empty();
} }