[Libreoffice-commits] core.git: vcl/win

Jan-Marek Glogowski glogow at fbihome.de
Tue Jul 25 14:15:34 UTC 2017


 vcl/win/app/salinst.cxx  |    5 ++++-
 vcl/win/app/saltimer.cxx |    3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 20ddcfb92afeec2da22cb8fd0feeb89014c2fc89
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Tue Jul 25 11:32:21 2017 +0200

    WIN don't process the SendMessage from DoYield
    
    Actually we just want to remove the SAL_MSG_TIMER_CALLBACK
    messages, but this seems to be impossible using PeekMessage,
    without the side effect of processing some messages:
    "During this call, the system delivers pending, nonqueued
    messages... Then the first queued message that matches the
    specified filter is retrieved.".
    
    But it is actually enought to ignore the SAL_MSG_THREADYIELD
    message send using SendMessage from DoYield, which can be
    filtered by using PM_QS_POSTMESSAGE.
    
    Probably this should be resolved not using PeekMessage at all
    by using a variable to hold the time of the last posted
    SAL_MSG_TIMER_CALLBACK message, so we just run the callback
    once, if our time is <= MSG time and ignore the multiple
    queued messages. Same for mbOnIdleRunScheduler handling.
    
    Change-Id: Ifacb20aa38e6b5aca908e5411cf2e100f702ad1f

diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index cfffb97d0234..6458fca73c43 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -644,6 +644,8 @@ bool WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong
         if( ImplGetSVData()->maAppData.mnModalMode )
             Sleep(1);
         else
+            // If you change the SendMessageW function, you might need to update
+            // the PeekMessage( ... PM_QS_POSTMESSAGE) calls!
             bDidWork = SendMessageW( mhComWnd, SAL_MSG_THREADYIELD, (WPARAM)bWait, (LPARAM)bHandleAllCurrentEvents );
 
         ImplSalAcquireYieldMutex( nCount );
@@ -729,8 +731,9 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, i
             break;
         case SAL_MSG_TIMER_CALLBACK:
             MSG aMsg;
+            // PM_QS_POSTMESSAGE is needed, so we don't process the SendMessage from DoYield!
             while ( PeekMessageW(&aMsg, nullptr, SAL_MSG_TIMER_CALLBACK,
-                                 SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD) )
+                                 SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD | PM_QS_POSTMESSAGE) )
                 assert( "Multiple timer messages in queue" );
             assert( 0 == wParam );
             if ( 0 == wParam )
diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx
index 4ca5ebb572d2..847ff52851b8 100644
--- a/vcl/win/app/saltimer.cxx
+++ b/vcl/win/app/saltimer.cxx
@@ -46,10 +46,11 @@ void ImplSalStopTimer()
     // remove all pending SAL_MSG_TIMER_CALLBACK messages
     // we always have to do this, since ImplSalStartTimer with 0ms just queues
     // a new SAL_MSG_TIMER_CALLBACK message
+    // PM_QS_POSTMESSAGE is needed, so we don't process the SendMessage from DoYield!
     MSG aMsg;
     int nMsgCount = 0;
     while ( PeekMessageW(&aMsg, nullptr, SAL_MSG_TIMER_CALLBACK,
-                         SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD) )
+                         SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD | PM_QS_POSTMESSAGE) )
         nMsgCount++;
     assert( nMsgCount <= 1 );
     pSalData->mbOnIdleRunScheduler = false;


More information about the Libreoffice-commits mailing list