[Libreoffice-commits] core.git: sw/source

Stephan Bergmann sbergman at redhat.com
Wed Oct 29 04:26:00 PDT 2014


 sw/source/core/inc/layact.hxx    |    9 +++++++--
 sw/source/core/layout/layact.cxx |   13 ++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit b9f080e012d0e4f5343da940079c20d3f9c63513
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 29 12:23:43 2014 +0100

    Fix -fsanitize=signed-integer-overflow
    
    ...when std::clock_t is sufficiently small.  Though the formula used in
    SwLayAction::CheckWaitCrsr does look odd...
    
    Change-Id: Iee32350850be4a1896c5cb41eff748f0cb5382a2

diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx
index 3d8d42c..897dc7e 100644
--- a/sw/source/core/inc/layact.hxx
+++ b/sw/source/core/inc/layact.hxx
@@ -18,6 +18,11 @@
  */
 #ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
 #define INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
+
+#include <sal/config.h>
+
+#include <ctime>
+
 #include "swtypes.hxx"
 #include "swrect.hxx"
 
@@ -62,7 +67,7 @@ class SwLayAction
     // The InternalAction can then take the appropriate steps.
     sal_uInt16 nPreInvaPage;
 
-    sal_uLong nStartTicks;      // The Action's starting time; if too much time passes the
+    std::clock_t nStartTicks;      // The Action's starting time; if too much time passes the
                                 // WaitCrsr can be enabled via CheckWaitCrsr()
 
     sal_uInt16 nInputType;      // Which input should terminate processing
@@ -111,7 +116,7 @@ class SwLayAction
     bool RemoveEmptyBrowserPages();
 
     inline void CheckIdleEnd();
-    inline sal_uLong GetStartTicks() { return nStartTicks; }
+    inline std::clock_t GetStartTicks() { return nStartTicks; }
 
 public:
     SwLayAction( SwRootFrm *pRt, SwViewImp *pImp );
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index ed0a031..f664f70 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -19,7 +19,7 @@
 
 #include <config_features.h>
 
-#include <time.h>
+#include <ctime>
 #include "rootfrm.hxx"
 #include "pagefrm.hxx"
 #include "viewimp.hxx"
@@ -99,16 +99,11 @@ static void BreakPoint()
         } \
     }
 
-inline sal_uLong Ticks()
-{
-    return 1000 * clock() / CLOCKS_PER_SEC;
-}
-
 void SwLayAction::CheckWaitCrsr()
 {
     RESCHEDULE
     if ( !IsWait() && IsWaitAllowed() && IsPaint() &&
-         ((Ticks() - GetStartTicks()) >= CLOCKS_PER_SEC/2) )
+         ((std::clock() - GetStartTicks()) * 1000 / CLOCKS_PER_SEC >= CLOCKS_PER_SEC/2) )
     {
         pWait = new SwWait( *pRoot->GetFmt()->GetDoc()->GetDocShell(), true );
     }
@@ -288,7 +283,7 @@ SwLayAction::SwLayAction( SwRootFrm *pRt, SwViewImp *pI ) :
     pOptTab( 0 ),
     pWait( 0 ),
     nPreInvaPage( USHRT_MAX ),
-    nStartTicks( Ticks() ),
+    nStartTicks( std::clock() ),
     nInputType( 0 ),
     nEndPage( USHRT_MAX ),
     nCheckPageNum( USHRT_MAX )
@@ -313,7 +308,7 @@ SwLayAction::~SwLayAction()
 void SwLayAction::Reset()
 {
     pOptTab = 0;
-    nStartTicks = Ticks();
+    nStartTicks = std::clock();
     nInputType = 0;
     nEndPage = nPreInvaPage = nCheckPageNum = USHRT_MAX;
     bPaint = bComplete = bWaitAllowed = bCheckPages = true;


More information about the Libreoffice-commits mailing list