From fd46a7766284d0b7f95ab925bf5113a92e91e129 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 5 Apr 2021 14:29:28 +0300 Subject: embedded cycle removed --- plugins/AVS/src/cache.cpp | 96 +++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'plugins') diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index aa246fb6e1..b54baa4d5c 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -232,59 +232,59 @@ void PicLoader(LPVOID) dwDelay = 100; while (!g_shutDown) { - while (!g_shutDown) { - CacheNode *node; - { - mir_cslock all(alloccs); - node = arQueue[0]; - if (node) - arQueue.remove(0); - } - if (node == nullptr) - break; + CacheNode *node; + { + mir_cslock all(alloccs); + node = arQueue[0]; + if (node) + arQueue.remove(0); + } - if (db_get_b(node->hContact, "ContactPhoto", "NeedUpdate", 0)) - QueueAdd(node->hContact); + if (node == nullptr) { + WaitForSingleObject(hLoaderEvent, INFINITE); + ResetEvent(hLoaderEvent); + continue; + } - AVATARCACHEENTRY ace_temp; - memcpy(&ace_temp, node, sizeof(AVATARCACHEENTRY)); - ace_temp.hbmPic = nullptr; - - int result = CreateAvatarInCache(node->hContact, &ace_temp, nullptr); - if (result == -2) { - char *szProto = Proto_GetBaseAccountName(node->hContact); - if (szProto == nullptr || Proto_NeedDelaysForAvatars(szProto)) - QueueAdd(node->hContact); - else if (FetchAvatarFor(node->hContact, szProto) == GAIR_SUCCESS) // Try to create again - result = CreateAvatarInCache(node->hContact, &ace_temp, nullptr); - } + if (db_get_b(node->hContact, "ContactPhoto", "NeedUpdate", 0)) + QueueAdd(node->hContact); - if (result == 1 && ace_temp.hbmPic != nullptr) { // Loaded - HBITMAP oldPic = node->hbmPic; - { - mir_cslock l(cachecs); - memcpy(node, &ace_temp, sizeof(AVATARCACHEENTRY)); - node->bLoaded = true; - } - if (oldPic) - DeleteObject(oldPic); - NotifyMetaAware(node->hContact, node); + AVATARCACHEENTRY ace_temp; + memcpy(&ace_temp, node, sizeof(AVATARCACHEENTRY)); + ace_temp.hbmPic = nullptr; + + int result = CreateAvatarInCache(node->hContact, &ace_temp, nullptr); + if (result == -2) { + char *szProto = Proto_GetBaseAccountName(node->hContact); + if (szProto == nullptr || Proto_NeedDelaysForAvatars(szProto)) + QueueAdd(node->hContact); + else if (FetchAvatarFor(node->hContact, szProto) == GAIR_SUCCESS) // Try to create again + result = CreateAvatarInCache(node->hContact, &ace_temp, nullptr); + } + + if (result == 1 && ace_temp.hbmPic != nullptr) { // Loaded + HBITMAP oldPic = node->hbmPic; + { + mir_cslock l(cachecs); + memcpy(node, &ace_temp, sizeof(AVATARCACHEENTRY)); + node->bLoaded = true; } - else if (result == 0 || result == -3) { // Has no avatar - HBITMAP oldPic = node->hbmPic; - { - mir_cslock l(cachecs); - memcpy(node, &ace_temp, sizeof(AVATARCACHEENTRY)); - node->bLoaded = false; - } - if (oldPic) - DeleteObject(oldPic); - NotifyMetaAware(node->hContact, node); + if (oldPic) + DeleteObject(oldPic); + NotifyMetaAware(node->hContact, node); + } + else if (result == 0 || result == -3) { // Has no avatar + HBITMAP oldPic = node->hbmPic; + { + mir_cslock l(cachecs); + memcpy(node, &ace_temp, sizeof(AVATARCACHEENTRY)); + node->bLoaded = false; } - - mir_sleep(dwDelay); + if (oldPic) + DeleteObject(oldPic); + NotifyMetaAware(node->hContact, node); } - WaitForSingleObject(hLoaderEvent, INFINITE); - ResetEvent(hLoaderEvent); + + mir_sleep(dwDelay); } } -- cgit v1.2.3