summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/modules.cpp50
-rw-r--r--src/mir_core/src/subclass.cpp13
-rw-r--r--src/mir_core/src/threads.cpp17
-rw-r--r--src/mir_core/src/windowlist.cpp8
4 files changed, 43 insertions, 45 deletions
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp
index c410084c65..b78c204aff 100644
--- a/src/mir_core/src/modules.cpp
+++ b/src/mir_core/src/modules.cpp
@@ -413,18 +413,18 @@ MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE hInst)
{
mir_cslock lck(csHooks);
- for (int i = hooks.getCount() - 1; i >= 0; i--) {
- if (hooks[i]->subscriberCount == 0)
+ for (auto &it : hooks.rev_iter()) {
+ if (it->subscriberCount == 0)
continue;
- for (int j = hooks[i]->subscriberCount - 1; j >= 0; j--) {
- if (hooks[i]->subscriber[j].hOwner != hInst)
+ for (int j = it->subscriberCount - 1; j >= 0; j--) {
+ if (it->subscriber[j].hOwner != hInst)
continue;
char szModuleName[MAX_PATH];
- GetModuleFileNameA(hooks[i]->subscriber[j].hOwner, szModuleName, sizeof(szModuleName));
- UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
- if (hooks[i]->subscriberCount == 0)
+ GetModuleFileNameA(it->subscriber[j].hOwner, szModuleName, sizeof(szModuleName));
+ UnhookEvent((HANDLE)((it->id << 16) + j + 1));
+ if (it->subscriberCount == 0)
break;
}
}
@@ -434,14 +434,14 @@ MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject)
{
mir_cslock lck(csHooks);
- for (int i = hooks.getCount() - 1; i >= 0; i--) {
- if (hooks[i]->subscriberCount == 0)
+ for (auto &it : hooks.rev_iter()) {
+ if (it->subscriberCount == 0)
continue;
- for (int j = hooks[i]->subscriberCount - 1; j >= 0; j--) {
- if (hooks[i]->subscriber[j].object == pObject) {
- UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
- if (hooks[i]->subscriberCount == 0)
+ for (int j = it->subscriberCount - 1; j >= 0; j--) {
+ if (it->subscriber[j].object == pObject) {
+ UnhookEvent((HANDLE)((it->id << 16) + j + 1));
+ if (it->subscriberCount == 0)
break;
}
}
@@ -452,11 +452,11 @@ static void DestroyHooks()
{
mir_cslock lck(csHooks);
- for (auto &p : hooks) {
- if (p->subscriberCount)
- mir_free(p->subscriber);
- DeleteCriticalSection(&p->csHook);
- mir_free(p);
+ for (auto &it : hooks) {
+ if (it->subscriberCount)
+ mir_free(it->subscriber);
+ DeleteCriticalSection(&it->csHook);
+ mir_free(it);
}
}
@@ -639,11 +639,11 @@ MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst)
{
mir_cslock lck(csServices);
- for (int i = services.getCount() - 1; i >= 0; i--) {
- if (services[i]->hOwner == hInst) {
+ for (auto &it : services.rev_iter()) {
+ if (it->hOwner == hInst) {
char szModuleName[MAX_PATH];
- GetModuleFileNameA(services[i]->hOwner, szModuleName, sizeof(szModuleName));
- DestroyServiceFunction((HANDLE)services[i]->nameHash);
+ GetModuleFileNameA(it->hOwner, szModuleName, sizeof(szModuleName));
+ DestroyServiceFunction((HANDLE)it->nameHash);
}
}
}
@@ -652,9 +652,9 @@ MIR_CORE_DLL(void) KillObjectServices(void* pObject)
{
mir_cslock lck(csServices);
- for (int i = services.getCount() - 1; i >= 0; i--)
- if (services[i]->object == pObject)
- DestroyServiceFunction((HANDLE)services[i]->nameHash);
+ for (auto &it : services.rev_iter())
+ if (it->object == pObject)
+ DestroyServiceFunction((HANDLE)it->nameHash);
}
static void DestroyServices()
diff --git a/src/mir_core/src/subclass.cpp b/src/mir_core/src/subclass.cpp
index c60eba41ad..d64fc3b5fb 100644
--- a/src/mir_core/src/subclass.cpp
+++ b/src/mir_core/src/subclass.cpp
@@ -179,16 +179,15 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg
MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst)
{
- for (int i = arSubclass.getCount() - 1; i >= 0; i--) {
- MSubclassData *p = arSubclass[i];
- for (int j = 0; j < p->m_iHooks; j++) {
- if (GetInstByAddress(p->m_hooks[j]) == hInst) {
- removeHook(p, j);
+ for (auto &it : arSubclass.rev_iter()) {
+ for (int j = 0; j < it->m_iHooks; j++) {
+ if (GetInstByAddress(it->m_hooks[j]) == hInst) {
+ removeHook(it, j);
j--;
}
}
- if (p->m_iHooks == 0)
- finalizeSubclassing(p->m_hWnd, p);
+ if (it->m_iHooks == 0)
+ finalizeSubclassing(it->m_hWnd, it);
}
}
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp
index 120cdeff1e..87a03fc62f 100644
--- a/src/mir_core/src/threads.cpp
+++ b/src/mir_core/src/threads.cpp
@@ -228,16 +228,15 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner)
if (WaitForMultipleObjects(threadCount, threadPool, TRUE, 5000) == WAIT_TIMEOUT) {
// forcibly kill all remaining threads after 5 secs
mir_cslock lck(csThreads);
- for (int j = threads.getCount() - 1; j >= 0; j--) {
- THREAD_WAIT_ENTRY *p = threads[j];
- if (p->pObject == owner) {
+ for (auto &it : threads.rev_iter()) {
+ if (it->pObject == owner) {
char szModuleName[MAX_PATH];
- GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, p->dwThreadId);
- TerminateThread(p->hThread, 9999);
- CloseHandle(p->hThread);
- threads.remove(j);
- mir_free(p);
+ GetModuleFileNameA(it->hOwner, szModuleName, sizeof(szModuleName));
+ Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, it->dwThreadId);
+ TerminateThread(it->hThread, 9999);
+ CloseHandle(it->hThread);
+ threads.remove(it);
+ mir_free(it);
}
}
}
diff --git a/src/mir_core/src/windowlist.cpp b/src/mir_core/src/windowlist.cpp
index a785472cbb..9fe88f5c33 100644
--- a/src/mir_core/src/windowlist.cpp
+++ b/src/mir_core/src/windowlist.cpp
@@ -89,8 +89,8 @@ MIR_CORE_DLL(int) WindowList_Broadcast(MWindowList hList, UINT message, WPARAM w
if (hList == nullptr)
return NULL;
- for (int i = hList->getCount()-1; i >= 0; i--)
- SendMessage((*hList)[i].hWnd, message, wParam, lParam);
+ for (auto &it : hList->rev_iter())
+ SendMessage(it->hWnd, message, wParam, lParam);
return 0;
}
@@ -99,7 +99,7 @@ MIR_CORE_DLL(int) WindowList_BroadcastAsync(MWindowList hList, UINT message, WPA
if (hList == nullptr)
return NULL;
- for (int i = hList->getCount()-1; i >= 0; i--)
- PostMessage((*hList)[i].hWnd, message, wParam, lParam);
+ for (auto &it : hList->rev_iter())
+ PostMessage(it->hWnd, message, wParam, lParam);
return 0;
}