commit 24e0bd3afea847218c0f590561cf172b3799432f
Author: Scott Kostyshak <[email protected]>
Date:   Sun Mar 15 20:32:16 2020 -0400

    Fix Qt deprecation warns for QTime
    
    This commit fixes a couple of warnings from Qt 5.14 like the
    following one:
    
      error: ‘int QTime::restart()’ is deprecated: Use QElapsedTimer instead 
[-Werror=deprecated-declarations]
    
    This commit changes two uses of QTime to QElapsedTimer, one used
    only when the "files" debug flag is set, and the other for timing
    whether a script (e.g., knitr) takes longer than a certain amount of
    time to run.
    
    QElapsedTimer is superior for these two use cases in that it uses a
    monotonic clock if possible, and is thus more robust to certain
    changes (e.g., daylight savings changes) [1]. Similarly, the commit
    in Qt Base that makes this deprecation [2] mentions the following in
    the commit message:
    
      QElapsedTimer does the job better and without the DST kludges.
    
    Note that QElapsedTimer class was introduced in Qt 4.7, so no
    conditioning on Qt version is necessary.
    
    Not all methods of QTime are deprecated and we still use some of
    the non-deprecated methods in our code (e.g., to get the current
    wall clock time in GuiProgress::currentTime()).
    
    [1] https://doc.qt.io/qt-5/qelapsedtimer.html
    [2] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=ed99a591a83a399458f12341d0a1c0b3152f247a
---
 src/support/FileName.cpp   |    4 ++--
 src/support/Systemcall.cpp |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index 505b485..179fef4 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -28,7 +28,7 @@
 #include <QFileInfo>
 #include <QList>
 #include <QTemporaryFile>
-#include <QTime>
+#include <QElapsedTimer>
 
 #ifdef _WIN32
 #include <QThread>
@@ -563,7 +563,7 @@ unsigned long FileName::checksum() const
        }
 
        // This is used in the debug output at the end of the method.
-       static QTime t;
+       static QElapsedTimer t;
        if (lyxerr.debugging(Debug::FILES))
                t.restart();
 
diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp
index f5b6c27..d0ff9ae 100644
--- a/src/support/Systemcall.cpp
+++ b/src/support/Systemcall.cpp
@@ -29,7 +29,7 @@
 #include <iostream>
 
 #include <QProcess>
-#include <QTime>
+#include <QElapsedTimer>
 #include <QThread>
 #include <QCoreApplication>
 #include <QDebug>
@@ -467,7 +467,7 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool 
process_events, int time
        }
 
        // process events while waiting with timeout
-       QTime timer;
+       QElapsedTimer timer;
        timer.start();
        while (state == waitwhile && state != Error && !timedout) {
                // check for cancellation of background process
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to