diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-15 21:05:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-15 21:05:06 +0300 |
commit | 59e6b15f513cc998ce13e9e49e2a6a3ace445ebb (patch) | |
tree | af52b73a17039ed1fbe398ba9f488c26a7071257 /plugins/Clist_modern/src | |
parent | bdaa5cf8b48515af2ac39f3f3245dd1183cbad52 (diff) |
LIST<> iterators:
- new method LIST::removeItem added to save a pointer to removed record;
- code cleaning related to the fact that LIST::remove() shall be the last operation inside an iterator, because otherwise the reference to it will point to a record next to deleted one;
- a few remaining cycles converted to iterators
Diffstat (limited to 'plugins/Clist_modern/src')
-rw-r--r-- | plugins/Clist_modern/src/modern_skinengine.cpp | 23 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_xptheme.cpp | 12 |
2 files changed, 16 insertions, 19 deletions
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 986de4cac7..d51deeebf1 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -527,21 +527,20 @@ int ske_ReleaseBufferDC(HDC hDC, int keepTime) //Try to find DC in buffer list - set flag to be release after time; mir_cslock lck(BufferListCS); - for (int i = 0; i < BufferList.getCount(); i++) { - DCBUFFER *pBuf = BufferList[i]; - if (pBuf) { - if (hDC != nullptr && pBuf->hDC == hDC) { - pBuf->dwDestroyAfterTime = dwCurrentTime + keepTime; + auto T = BufferList.rev_iter(); + for (auto &it : T) { + if (it) { + if (hDC != nullptr && it->hDC == hDC) { + it->dwDestroyAfterTime = dwCurrentTime + keepTime; break; } - if ((pBuf->dwDestroyAfterTime && pBuf->dwDestroyAfterTime < dwCurrentTime) || keepTime == -1) { - SelectObject(pBuf->hDC, pBuf->oldBitmap); - DeleteObject(pBuf->hBitmap); - DeleteDC(pBuf->hDC); - mir_free(pBuf); - BufferList.remove(i); - i--; + if ((it->dwDestroyAfterTime && it->dwDestroyAfterTime < dwCurrentTime) || keepTime == -1) { + SelectObject(it->hDC, it->oldBitmap); + DeleteObject(it->hBitmap); + DeleteDC(it->hDC); + mir_free(it); + BufferList.remove(T.indexOf(&it)); } } } diff --git a/plugins/Clist_modern/src/modern_xptheme.cpp b/plugins/Clist_modern/src/modern_xptheme.cpp index 6122fa21f6..bff9e8a7fb 100644 --- a/plugins/Clist_modern/src/modern_xptheme.cpp +++ b/plugins/Clist_modern/src/modern_xptheme.cpp @@ -72,14 +72,12 @@ void xpt_FreeThemeHandle(XPTHANDLE xptHandle) void xpt_FreeThemeForWindow(HWND hwnd)
{
mir_cslock lck(xptCS);
- for (int i = 0; i < xptObjectList.getCount();) {
- XPTObject& xptObject = xptObjectList[i];
- if (xptObject.hOwnerWindow == hwnd) {
- _sttXptCloseThemeData(&xptObject);
- xptObjectList.remove(i);
+ auto T = xptObjectList.rev_iter();
+ for (auto &xptObject : T)
+ if (xptObject->hOwnerWindow == hwnd) {
+ _sttXptCloseThemeData(xptObject);
+ xptObjectList.remove(T.indexOf(&xptObject));
}
- else i++;
- }
}
void xpt_OnWM_THEMECHANGED()
|