summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-12 21:03:45 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-12 21:03:45 +0300
commit2f112b300d2c5582b9a614ce3588d6d6879bcd1c (patch)
treea22e1cac3e346f12f8bcb032ab30892ffdf4698e
parent007cece71aebe64dafc824894270e4661416dcfc (diff)
Telegram: fix for occasional crash
-rw-r--r--protocols/Telegram/src/utils.cpp22
-rw-r--r--src/mir_core/src/db.cpp17
2 files changed, 24 insertions, 15 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index 627e11eda5..9ef0809d38 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -738,15 +738,21 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
}
if (m_bSmileyAdd) {
- const char *pwszFileExt;
- switch (pSticker->format_->get_id()) {
- case TD::stickerFormatTgs::ID: pwszFileExt = "tga"; break;
- case TD::stickerFormatWebm::ID: pwszFileExt = "webm"; break;
- case TD::stickerFormatWebp::ID: pwszFileExt = "webp"; break;
- default:pwszFileExt = "jpeg"; break;
+ if (pSticker->thumbnail_.get()) {
+ const char *pwszFileExt;
+ switch (pSticker->format_->get_id()) {
+ case TD::stickerFormatTgs::ID: pwszFileExt = "tga"; break;
+ case TD::stickerFormatWebm::ID: pwszFileExt = "webm"; break;
+ case TD::stickerFormatWebp::ID: pwszFileExt = "webp"; break;
+ default:
+ pwszFileExt = "jpeg"; break;
+ }
+ ret = GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt);
+ }
+ else {
+ debugLogA("Strange sticker without preview");
+ ret.Append(pSticker->emoji_.c_str());
}
-
- ret = GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt);
}
else ret.AppendFormat("%s: %s", TranslateU("SmileyAdd plugin required to support stickers"), pSticker->emoji_.c_str());
}
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index b691461e66..9527537a4d 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -485,16 +485,19 @@ MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent, bool bFr
{
if (g_pCurrDb == nullptr)
return 1;
-
- if (!g_pCurrDb->MarkEventRead(hContact, hDbEvent))
- return 1;
+ // we received remote mark read command
if (bFromServer)
CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_READ);
- else if (auto *ppro = Proto_GetInstance(hContact)) {
- ppro->OnMarkRead(hContact, hDbEvent);
- return 0;
- }
+
+ if (!g_pCurrDb->MarkEventRead(hContact, hDbEvent))
+ return 1;
+
+ if (!bFromServer)
+ if (auto *ppro = Proto_GetInstance(hContact)) {
+ ppro->OnMarkRead(hContact, hDbEvent);
+ return 0;
+ }
return 1;
}