uiTimer() Use TimerHandler pointers directly as Windows timer IDs
This commit is contained in:
parent
c9d11a85cc
commit
d99549ec18
|
@ -1,7 +1,6 @@
|
|||
// 6 april 2015
|
||||
#include "uipriv_windows.hpp"
|
||||
|
||||
std::map<UINT_PTR, TimerHandler> timerHandlers;
|
||||
static HHOOK filter;
|
||||
|
||||
static LRESULT CALLBACK filterProc(int code, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -132,10 +131,9 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
|||
|
||||
void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
||||
{
|
||||
UINT_PTR id = timerHandlers.size() + 1;
|
||||
while (timerHandlers.find(id) != timerHandlers.end())
|
||||
id++;
|
||||
if (SetTimer(utilWindow, id, milliseconds, NULL) == 0)
|
||||
UINT_PTR timer;
|
||||
|
||||
timer = (UINT_PTR) new TimerHandler(f, data);
|
||||
if (SetTimer(utilWindow, timer, milliseconds, NULL) == 0)
|
||||
logLastError(L"SetTimer()");
|
||||
timerHandlers[id] = TimerHandler(f, data);
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ private:
|
|||
};
|
||||
extern int registerMessageFilter(void);
|
||||
extern void unregisterMessageFilter(void);
|
||||
extern std::map<UINT_PTR, TimerHandler> timerHandlers;
|
||||
|
||||
// parent.cpp
|
||||
extern void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect);
|
||||
|
|
|
@ -18,7 +18,7 @@ static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
|||
{
|
||||
void (*qf)(void *);
|
||||
LRESULT lResult;
|
||||
UINT_PTR id;
|
||||
TimerHandler *timer;
|
||||
|
||||
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
|
||||
return lResult;
|
||||
|
@ -38,11 +38,11 @@ static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
|||
(*qf)((void *) lParam);
|
||||
return 0;
|
||||
case WM_TIMER:
|
||||
id = (UINT_PTR)wParam;
|
||||
if (!timerHandlers[id]()) {
|
||||
if (!KillTimer(utilWindow, id))
|
||||
timer = (TimerHandler *) wParam;
|
||||
if (!(*timer)()) {
|
||||
if (!KillTimer(utilWindow, (UINT_PTR) timer))
|
||||
logLastError(L"KillTimer()");
|
||||
timerHandlers.erase(id);
|
||||
delete timer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue