summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-06-05 18:26:15 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-06-05 18:26:19 +0300
commitba49b7d5d231cfb886b2fa9ee838d32bcb0a59ab (patch)
treee2a714c0de93e63b624282477f1dd608ba9ac332
parent0746936b41f94cd39cb9760f2aa48799b5da4314 (diff)
Discord: fix for a rare crash
-rw-r--r--protocols/Discord/src/dispatch.cpp44
1 files 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());
+
}
/////////////////////////////////////////////////////////////////////////////////////////