From 2f112b300d2c5582b9a614ce3588d6d6879bcd1c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 12 Oct 2024 21:03:45 +0300 Subject: Telegram: fix for occasional crash --- src/mir_core/src/db.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/mir_core') 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; } -- cgit v1.2.3