Fix processing of pending events in mixed MFC/wx applications

ProcessPendingEvents() was never called when using MFC event loop,
meaning that queued events were never processed, so that using
CallAfter() didn't work.

Fix this and also ensure that these events are processed soon enough by
also implementing WakeUpIdle() for such applications, as wxWakeUpIdle()
didn't do anything neither for them.
This commit is contained in:
Vadim Zeitlin
2018-01-27 18:58:13 +01:00
parent 264f93aad9
commit 160647aaf2

View File

@@ -113,8 +113,13 @@ public:
{
BOOL moreIdle = BaseApp::OnIdle(lCount);
if ( wxTheApp && wxTheApp->ProcessIdle() )
moreIdle = TRUE;
if ( wxTheApp )
{
wxTheApp->ProcessPendingEvents();
if ( wxTheApp->ProcessIdle() )
moreIdle = TRUE;
}
return moreIdle;
}
@@ -172,6 +177,17 @@ public:
// instead.
::PostQuitMessage(0);
}
void WakeUpIdle() wxOVERRIDE
{
// As above, we can't wake up any wx event loop, so try to wake up the
// MFC one instead.
CWinApp* const mfcApp = AfxGetApp();
if ( mfcApp && mfcApp->m_pMainWnd )
{
::PostMessage(mfcApp->m_pMainWnd->m_hWnd, WM_NULL, 0, 0);
}
}
};
#endif // _WX_MSW_MFC_H_