- [WebParser] Fixed minor memory leak.

- [WebParser] Modified the routine which finds the Rainmeter window.
This commit is contained in:
spx 2010-08-24 20:23:22 +00:00
parent 877d4a3f4d
commit 5b7a985a7e

View File

@ -159,41 +159,42 @@ std::string ConvertAsciiToUTF8(LPCSTR str, int codepage)
return szUTF8; return szUTF8;
} }
HWND FindMeterWindow() bool BelongToSameProcess(HWND wnd)
{ {
HWND wnd = FindWindow(L"RainmeterMeterWindow", NULL); DWORD procId = 0;
if (wnd == NULL) GetWindowThreadProcessId(wnd, &procId);
return (procId == GetCurrentProcessId());
}
HWND FindMeterWindow(HWND parent = NULL)
{
HWND wnd = NULL;
while (wnd = FindWindowEx(parent, wnd, L"RainmeterMeterWindow", NULL))
{ {
// Check if all windows are "On Desktop" if (BelongToSameProcess(wnd))
HWND ProgmanHwnd = FindWindow(L"Progman", L"Program Manager");
if (ProgmanHwnd)
{ {
wnd = FindWindowEx(ProgmanHwnd, NULL, L"RainmeterMeterWindow", NULL); return wnd;
if (wnd == NULL) }
}
// for backward compatibility (0.14 - 1.1)
if (!parent)
{ {
ProgmanHwnd = FindWindowEx(FindWindowEx(ProgmanHwnd, NULL, L"SHELLDLL_DefView", L""), NULL, L"SysListView32", L"FolderView"); while (parent = FindWindowEx(NULL, parent, L"Progman", NULL))
if (ProgmanHwnd)
{ {
wnd = FindWindowEx(ProgmanHwnd, NULL, L"RainmeterMeterWindow", NULL); if (wnd = FindMeterWindow(parent))
{
if (BelongToSameProcess(wnd))
{
return wnd;
}
} }
} }
} }
if (wnd == NULL) return NULL;
{
HWND WorkerWHwnd = NULL;
while ((WorkerWHwnd = FindWindowEx(NULL, WorkerWHwnd, L"WorkerW", L"")) != NULL)
{
ProgmanHwnd = FindWindowEx(FindWindowEx(WorkerWHwnd, NULL, L"SHELLDLL_DefView", L""), NULL, L"SysListView32", L"FolderView");
if (ProgmanHwnd)
{
wnd = FindWindowEx(ProgmanHwnd, NULL, L"RainmeterMeterWindow", NULL);
break;
}
}
}
}
return wnd;
} }
/* /*
@ -617,6 +618,9 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
} }
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
} }
// Release memory used for the compiled pattern
pcre_free(re);
} }
else else
{ {