wxEventLoopBase *m_evtLoopOld;
};
+class wxEventLoopGuarantor
+{
+public:
+ wxEventLoopGuarantor()
+ {
+ m_evtLoopNew = NULL;
+ if (!wxEventLoop::GetActive())
+ {
+ m_evtLoopNew = new wxEventLoop;
+ wxEventLoop::SetActive(m_evtLoopNew);
+ }
+ }
+
+ ~wxEventLoopGuarantor()
+ {
+ if (m_evtLoopNew)
+ {
+ wxEventLoop::SetActive(NULL);
+ delete m_evtLoopNew;
+ }
+ }
+
+private:
+ wxEventLoop *m_evtLoopNew;
+};
+
#endif // _WX_EVTLOOP_H_
s_inYield = true;
+ wxEventLoopGuarantor dummyLoopIfNeeded;
while (wxTheApp && wxTheApp->Pending())
wxTheApp->Dispatch();
// we don't want to process WM_QUIT from here - it should be processed in
// the main event loop in order to stop it
+ wxEventLoopGuarantor dummyLoopIfNeeded;
MSG msg;
while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
msg.message != WM_QUIT )
// We want to go back to the main message loop
// if we see a WM_QUIT. (?)
//
+ wxEventLoopGuarantor dummyLoopIfNeeded;
while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
{
#if wxUSE_THREADS
// Make sure we have an event loop object,
// or Pending/Dispatch will fail
- wxEventLoopBase * const eventLoop = wxEventLoop::GetActive();
- wxEventLoop* newEventLoop = NULL;
- if (!eventLoop)
- {
- newEventLoop = new wxEventLoop;
- wxEventLoop::SetActive(newEventLoop);
- }
-
+ wxEventLoopGuarantor dummyLoopIfNeeded;
// Call dispatch at least once so that sockets
// can be tested
wxTheApp->Dispatch();
#endif
ProcessIdle();
- if (newEventLoop)
- {
- wxEventLoop::SetActive(NULL);
- delete newEventLoop;
- }
-
s_inYield = false;
}