From 160647aaf24f0d0e4d3605aaacbe4db476baf835 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Jan 2018 18:58:13 +0100 Subject: [PATCH] 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. --- include/wx/msw/mfc.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/wx/msw/mfc.h b/include/wx/msw/mfc.h index 830db351ac..f670b1b843 100644 --- a/include/wx/msw/mfc.h +++ b/include/wx/msw/mfc.h @@ -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_