From 4dac8bd56f9116ac76423b2664286ed894ca80c2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 20 Dec 2023 11:54:33 +0300 Subject: =?UTF-8?q?fixes=20#4068=20(NewStory:=20=D0=A2=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D0=BE=D0=B7=D0=B0=20=D0=B2=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_control.cpp | 20 ++++++++++++++++++++ plugins/NewStory/src/history_control.h | 1 + 2 files changed, 21 insertions(+) diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index a7cdcde421..f56d5b4661 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -112,13 +112,32 @@ void NewstoryListData::AddChatEvent(SESSION_INFO *si, const LOGINFO *lin) totalCount++; } +///////////////////////////////////////////////////////////////////////////////////////// + +static void __cdecl sttLoadItems(void *param) +{ + SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN); + + auto *pData = (NewstoryListData *)param; + for (int i = pData->totalCount-1; i >= 0; i--) { + pData->LoadItem(i); + if ((i % 100) == 0) + Sleep(50); + } +} + void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount) { ScheduleDraw(); items.addEvent(hContact, hFirstEvent, iCount); totalCount = items.getCount(); + + if (iCount == -1) + mir_forkthread(sttLoadItems, this); } +///////////////////////////////////////////////////////////////////////////////////////// + void NewstoryListData::AddResults(const OBJLIST &results) { ScheduleDraw(); @@ -538,6 +557,7 @@ ItemData* NewstoryListData::LoadItem(int idx) if (totalCount == 0) return nullptr; + mir_cslock lck(m_csItems); return (bSortAscending) ? items.get(idx, true) : items.get(totalCount - 1 - idx, true); } diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 463bfe15c2..f18ee1793d 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -7,6 +7,7 @@ struct NewstoryListData : public MZeroedObject { NewstoryListData(HWND); + mir_cs m_csItems; HistoryArray items; int scrollTopItem; // topmost item -- cgit v1.2.3