summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-26 21:29:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-26 21:29:14 +0300
commitf57ac413fffff5327e976cf5aaee8e307fbadcf5 (patch)
tree1db869f66777fdbf4b4569fa36940bd0b2ec63f2 /src/mir_app
parent8045ce62630366301881db691c06db51de4e2fe4 (diff)
faster & safer code of removing user from a group chat
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/chat_manager.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index d5a268dd72..2bedd3c536 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -826,19 +826,23 @@ static wchar_t* UM_FindUserAutoComplete(SESSION_INFO *si, const wchar_t* pszOrig
static BOOL UM_RemoveUser(SESSION_INFO *si, const wchar_t *pszUID)
{
- if (!si || !pszUID)
+ auto *pUser = UM_FindUser(si, pszUID);
+ if (pUser == nullptr)
return FALSE;
+ auto &arKeys = si->getKeyList();
+ arKeys.remove(pUser);
+
auto &arUsers = si->getUserList();
for (auto &ui : arUsers) {
if (!mir_wstrcmpi(ui->pszUID, pszUID)) {
mir_free(ui->pszNick);
mir_free(ui->pszUID);
arUsers.remove(arUsers.indexOf(&ui));
- return TRUE;
+ break;
}
}
- return FALSE;
+ return TRUE;
}
BOOL UM_RemoveAll(SESSION_INFO *si)