Cleaned up timers in uiUninit() on Windows. Update #395.
This commit is contained in:
parent
075d5efb61
commit
ad1641f9ab
|
@ -140,6 +140,7 @@ const char *uiInit(uiInitOptions *o)
|
||||||
|
|
||||||
void uiUninit(void)
|
void uiUninit(void)
|
||||||
{
|
{
|
||||||
|
uiprivUninitTimers();
|
||||||
uiprivUninitImage();
|
uiprivUninitImage();
|
||||||
uninitMenus();
|
uninitMenus();
|
||||||
unregisterD2DScratchClass();
|
unregisterD2DScratchClass();
|
||||||
|
|
|
@ -129,6 +129,8 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
||||||
logLastError(L"error queueing function to run on main thread");
|
logLastError(L"error queueing function to run on main thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::map<uiprivTimer *, bool> timers;
|
||||||
|
|
||||||
void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
||||||
{
|
{
|
||||||
uiprivTimer *timer;
|
uiprivTimer *timer;
|
||||||
|
@ -139,4 +141,19 @@ void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
||||||
// note that timer IDs are pointer sized precisely so we can use them as timer IDs; see https://blogs.msdn.microsoft.com/oldnewthing/20150924-00/?p=91521
|
// note that timer IDs are pointer sized precisely so we can use them as timer IDs; see https://blogs.msdn.microsoft.com/oldnewthing/20150924-00/?p=91521
|
||||||
if (SetTimer(utilWindow, (UINT_PTR) timer, milliseconds, NULL) == 0)
|
if (SetTimer(utilWindow, (UINT_PTR) timer, milliseconds, NULL) == 0)
|
||||||
logLastError(L"error calling SetTimer() in uiTimer()");
|
logLastError(L"error calling SetTimer() in uiTimer()");
|
||||||
|
timers[timer] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiprivFreeTimer(uiprivTimer *t)
|
||||||
|
{
|
||||||
|
timers.erase(t);
|
||||||
|
uiprivFree(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiprivUninitTimers(void)
|
||||||
|
{
|
||||||
|
// TODO why doesn't auto t : timers work?
|
||||||
|
for (auto t = timers.begin(); t != timers.end(); t++)
|
||||||
|
uiprivFree(t->first);
|
||||||
|
timers.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,8 @@ struct uiprivTimer {
|
||||||
};
|
};
|
||||||
extern int registerMessageFilter(void);
|
extern int registerMessageFilter(void);
|
||||||
extern void unregisterMessageFilter(void);
|
extern void unregisterMessageFilter(void);
|
||||||
|
extern void uiprivFreeTimer(uiprivTimer *t);
|
||||||
|
extern void uiprivUninitTimers(void);
|
||||||
|
|
||||||
// parent.cpp
|
// parent.cpp
|
||||||
extern void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect);
|
extern void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect);
|
||||||
|
|
|
@ -42,7 +42,7 @@ static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
||||||
if (!(*(timer->f))(timer->data)) {
|
if (!(*(timer->f))(timer->data)) {
|
||||||
if (KillTimer(utilWindow, (UINT_PTR) timer) == 0)
|
if (KillTimer(utilWindow, (UINT_PTR) timer) == 0)
|
||||||
logLastError(L"error calling KillTimer() to end uiTimer() procedure");
|
logLastError(L"error calling KillTimer() to end uiTimer() procedure");
|
||||||
uiprivFree(timer);
|
uiprivFreeTimer(timer);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue