diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-20 11:54:33 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-20 11:54:33 +0300 |
commit | 4dac8bd56f9116ac76423b2664286ed894ca80c2 (patch) | |
tree | 3ef2088f0fcd17e8e8f22f10fa5aa018cd428c5f | |
parent | 14d3913fe7e41d56d6d6fd18711ef95e2e72ab85 (diff) |
fixes #4068 (NewStory: Тормоза в поиске)
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 20 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 1 |
2 files changed, 21 insertions, 0 deletions
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<SearchResult> &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 |