diff options
author | George Hazan <ghazan@miranda.im> | 2021-04-05 14:29:28 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-04-05 14:29:28 +0300 |
commit | fd46a7766284d0b7f95ab925bf5113a92e91e129 (patch) | |
tree | 522a1c47e5d49851fd6b39a6e221feb393c85dd8 /plugins | |
parent | d18819b23a4d12d1ca49c40165962c2a51db0f74 (diff) |
embedded cycle removed
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/AVS/src/cache.cpp | 96 |
1 files changed, 48 insertions, 48 deletions
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);
}
}
|