From ba49b7d5d231cfb886b2fa9ee838d32bcb0a59ab Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 5 Jun 2024 18:26:15 +0300 Subject: Discord: fix for a rare crash --- protocols/Discord/src/dispatch.cpp | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index e56d29eec1..3d886f3eb2 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -203,30 +203,34 @@ void CDiscordProto::OnCommandChannelUpdated(const JSONNode &pRoot) } // if a topic was changed - CMStringW wszTopic = pRoot["topic"].as_mstring(); - Chat_SetStatusbarText(pUser->si, wszTopic); - { - GCEVENT gce = { pUser->si, GC_EVENT_TOPIC }; - gce.pszText.w = wszTopic; - gce.time = time(0); - Chat_Event(&gce); - } - - // reset members info for private channels - if (pUser->pGuild == nullptr) { - CheckAvatarChange(pUser->hContact, pRoot["icon"].as_mstring()); - - for (auto &it : pUser->si->arUsers) { - SnowFlake userId = _wtoi64(it->pszUID); - - GCEVENT gce = { pUser->si, GC_EVENT_SETSTATUS }; - gce.pszUID.w = it->pszUID; - gce.pszStatus.w = (userId == ownerId) ? L"Owners" : L"Participants"; - gce.bIsMe = userId == m_ownId; + if (auto *si = pUser->si) { + CMStringW wszTopic = pRoot["topic"].as_mstring(); + Chat_SetStatusbarText(si, wszTopic); + { + GCEVENT gce = { si, GC_EVENT_TOPIC }; + gce.pszText.w = wszTopic; gce.time = time(0); Chat_Event(&gce); } + + // reset members info for private channels + if (!pUser->pGuild) { + for (auto &it : si->arUsers) { + SnowFlake userId = _wtoi64(it->pszUID); + + GCEVENT gce = { si, GC_EVENT_SETSTATUS }; + gce.pszUID.w = it->pszUID; + gce.pszStatus.w = (userId == ownerId) ? L"Owners" : L"Participants"; + gce.bIsMe = userId == m_ownId; + gce.time = time(0); + Chat_Event(&gce); + } + } } + + if (!pUser->pGuild) + CheckAvatarChange(pUser->hContact, pRoot["icon"].as_mstring()); + } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3