summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-15 21:05:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-15 21:05:06 +0300
commit59e6b15f513cc998ce13e9e49e2a6a3ace445ebb (patch)
treeaf52b73a17039ed1fbe398ba9f488c26a7071257 /plugins
parentbdaa5cf8b48515af2ac39f3f3245dd1183cbad52 (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')
-rw-r--r--plugins/Clist_modern/src/modern_skinengine.cpp23
-rw-r--r--plugins/Clist_modern/src/modern_xptheme.cpp12
-rw-r--r--plugins/NewXstatusNotify/src/xstatus.cpp6
-rw-r--r--plugins/Popup/src/popup_thread.cpp9
-rw-r--r--plugins/Popup/src/services.cpp2
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp7
-rw-r--r--plugins/SmileyAdd/src/download.cpp5
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp6
-rw-r--r--plugins/StatusManager/src/main.cpp2
-rw-r--r--plugins/UserInfoEx/src/mir_contactqueue.cpp4
10 files changed, 39 insertions, 37 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()
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp
index c15cf4e746..0267704979 100644
--- a/plugins/NewXstatusNotify/src/xstatus.cpp
+++ b/plugins/NewXstatusNotify/src/xstatus.cpp
@@ -46,8 +46,8 @@ void RemoveLoggedEventsXStatus(MCONTACT hContact)
for (auto &it : T)
if (it->hContact == hContact) {
db_event_delete(it->hContact, it->hDBEvent);
- eventListXStatus.remove(T.indexOf(&it));
mir_free(it);
+ eventListXStatus.remove(T.indexOf(&it));
}
}
@@ -57,8 +57,8 @@ void RemoveLoggedEventsStatus(MCONTACT hContact)
for (auto &it : T)
if (it->hContact == hContact) {
db_event_delete(it->hContact, it->hDBEvent);
- eventListStatus.remove(T.indexOf(&it));
mir_free(it);
+ eventListStatus.remove(T.indexOf(&it));
}
}
@@ -68,8 +68,8 @@ void RemoveLoggedEventsSMsg(MCONTACT hContact)
for (auto &it : T)
if (it->hContact == hContact) {
db_event_delete(it->hContact, it->hDBEvent);
- eventListSMsg.remove(T.indexOf(&it));
mir_free(it);
+ eventListSMsg.remove(T.indexOf(&it));
}
}
diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp
index 75e306a0b8..5caede1cf1 100644
--- a/plugins/Popup/src/popup_thread.cpp
+++ b/plugins/Popup/src/popup_thread.cpp
@@ -179,9 +179,12 @@ static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARA
break;
case UTM_REMOVE_WINDOW:
- for (int i = popupList.getCount() - 1; i >= 0; i--)
- if (popupList[i] == wnd)
- popupList.remove(i);
+ {
+ auto T = popupList.rev_iter();
+ for (auto &it : T)
+ if (it == wnd)
+ popupList.remove(T.indexOf(&it));
+ }
RepositionPopups();
--nPopups;
diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp
index b1d659d241..e6f09614cc 100644
--- a/plugins/Popup/src/services.cpp
+++ b/plugins/Popup/src/services.cpp
@@ -419,7 +419,7 @@ INT_PTR Popup_UnregisterPopupClass(WPARAM, LPARAM lParam)
for (auto &it : gTreeData)
if (it == ptd) {
- gTreeData.remove(it);
+ gTreeData.removeItem(&it);
FreePopupClass(ptd);
return 0;
}
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index b530245b6b..d0c720b2e7 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -310,10 +310,9 @@ int GetStatus(MCONTACT hContact, char *proto = nullptr)
void FreeContacts()
{
- for (int i = contacts.getCount() - 1; i >= 0; i--) {
- delete contacts[i];
- contacts.remove(i);
- }
+ for (auto &it : contacts)
+ delete it;
+ contacts.destroy();
}
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp
index 7633dffab0..306b980276 100644
--- a/plugins/SmileyAdd/src/download.cpp
+++ b/plugins/SmileyAdd/src/download.cpp
@@ -136,7 +136,10 @@ void __cdecl SmileyDownloadThread(void*)
WaitForSingleObject(g_hDlMutex, 3000);
CMStringW fname(dlQueue[0].fname);
- if (dlQueue[0].needext) { fname += GetImageExt(fname); needext = true; }
+ if (dlQueue[0].needext) {
+ fname += GetImageExt(fname);
+ needext = true;
+ }
_wrename(dlQueue[0].fname.c_str(), fname.c_str());
}
else WaitForSingleObject(g_hDlMutex, 3000);
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index 16de9ebdf9..5b07d56bd4 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -762,9 +762,9 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc)
}
}
- for (int i = 0; i < m_SmileyCategories.getCount(); i++) {
- if (tname.CompareNoCase(m_SmileyCategories[i].GetName()) == 0) {
- m_SmileyCategories.remove(i);
+ for (auto &it : m_SmileyCategories) {
+ if (tname.CompareNoCase(it->GetName()) == 0) {
+ m_SmileyCategories.removeItem(&it);
break;
}
}
diff --git a/plugins/StatusManager/src/main.cpp b/plugins/StatusManager/src/main.cpp
index 651123f71c..5d5db295e3 100644
--- a/plugins/StatusManager/src/main.cpp
+++ b/plugins/StatusManager/src/main.cpp
@@ -105,7 +105,7 @@ int OnAccChanged(WPARAM wParam, LPARAM lParam)
case PRAC_REMOVED:
for (auto &it : protoList) {
if (!mir_strcmp(it->m_szName, pa->szModuleName)) {
- protoList.remove(it);
+ protoList.removeItem(&it);
break;
}
}
diff --git a/plugins/UserInfoEx/src/mir_contactqueue.cpp b/plugins/UserInfoEx/src/mir_contactqueue.cpp
index 9ba36425ad..f74a5c1795 100644
--- a/plugins/UserInfoEx/src/mir_contactqueue.cpp
+++ b/plugins/UserInfoEx/src/mir_contactqueue.cpp
@@ -86,8 +86,8 @@ void CContactQueue::RemoveAll(MCONTACT hContact)
auto T = _queue.rev_iter();
for (auto &qi : T) {
if (qi->hContact == hContact) {
- _queue.remove(T.indexOf(&qi));
mir_free(qi);
+ _queue.remove(T.indexOf(&qi));
}
}
}
@@ -102,8 +102,8 @@ void CContactQueue::RemoveAllConsiderParam(MCONTACT hContact, PVOID param)
auto T = _queue.rev_iter();
for (auto &qi : T)
if (qi->hContact == hContact && qi->param == param) {
- _queue.remove(T.indexOf(&qi));
mir_free(qi);
+ _queue.remove(T.indexOf(&qi));
}
}