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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 27 13:13:19 UTC 2018


 vcl/inc/win/saltimer.h   |    1 +
 vcl/win/app/saltimer.cxx |   11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 0073101ec520e40727800f1d90b3b211fd6ec8d8
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Sat Aug 25 02:56:32 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Mon Aug 27 15:12:58 2018 +0200

    WIN use the SetTimer timer as one-shot
    
    SetTimer is a continuous timer, but we want to use it as a
    one-shot, so make sure we actually kill it when not needed.
    
    Change-Id: If6f5374346dc530eb664545ade2c2955885941b5
    Reviewed-on: https://gerrit.libreoffice.org/59589
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h
index e3fc25a3f542..3dd18f0a485f 100644
--- a/vcl/inc/win/saltimer.h
+++ b/vcl/inc/win/saltimer.h
@@ -39,6 +39,7 @@ class WinSalTimer final : public SalTimer, protected VersionedEvent
     HANDLE       m_nTimerId;          ///< Windows timer id
     bool         m_bDirectTimeout;    ///< timeout can be processed directly
     bool         m_bForceRealTimer;   ///< enforce using a real timer for 0ms
+    bool         m_bSetTimerRunning;  ///< true, if a SetTimer is running
 
     void ImplStart( sal_uIntPtr nMS );
     void ImplStop();
diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx
index 17478bf58fdd..e89dbd561425 100644
--- a/vcl/win/app/saltimer.cxx
+++ b/vcl/win/app/saltimer.cxx
@@ -42,8 +42,11 @@ void WinSalTimer::ImplStop()
     const WinSalInstance *pInst = pSalData->mpInstance;
     assert( !pInst || pSalData->mnAppThreadId == GetCurrentThreadId() );
 
-    if ( m_bForceRealTimer && m_bDirectTimeout )
+    if ( m_bSetTimerRunning )
+    {
+        m_bSetTimerRunning = false;
         KillTimer( GetSalData()->mpInstance->mhComWnd, m_aWmTimerId );
+    }
     m_bDirectTimeout = false;
 
     const HANDLE hTimer = m_nTimerId;
@@ -83,6 +86,7 @@ void WinSalTimer::ImplStart( sal_uLong nMS )
         // with posted 0ms SAL_MSG_TIMER_CALLBACK messages
         SetTimer( GetSalData()->mpInstance->mhComWnd, m_aWmTimerId,
                   USER_TIMER_MINIMUM, nullptr );
+        m_bSetTimerRunning = true;
     }
     // we don't need any wakeup message, as this code can just run in the
     // main thread!
@@ -92,6 +96,7 @@ WinSalTimer::WinSalTimer()
     : m_nTimerId( nullptr )
     , m_bDirectTimeout( false )
     , m_bForceRealTimer( false )
+    , m_bSetTimerRunning( false )
 {
 }
 
@@ -183,9 +188,11 @@ void WinSalTimer::SetForceRealTimer( const bool bVal )
 void WinSalTimer::ImplHandle_WM_TIMER( const WPARAM aWPARAM )
 {
     assert( m_aWmTimerId == aWPARAM );
-    if ( !(m_aWmTimerId == aWPARAM && m_bDirectTimeout && m_bForceRealTimer) )
+    if ( !(m_aWmTimerId == aWPARAM && m_bSetTimerRunning) )
         return;
 
+    m_bSetTimerRunning = false;
+    KillTimer( GetSalData()->mpInstance->mhComWnd, m_aWmTimerId );
     ImplHandleElapsedTimer();
 }
 


More information about the Libreoffice-commits mailing list