From: Scott Kostyshak Date: Mon, 16 Mar 2020 00:32:16 +0000 (-0400) Subject: Fix Qt deprecation warns for QTime X-Git-Tag: lyx-2.4.0dev-acb2ca7b~1103 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=24e0bd3afea847218c0f590561cf172b3799432f;p=features.git 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 --- diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 505b485d7f..179fef46ee 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #ifdef _WIN32 #include @@ -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 f5b6c27a50..d0ff9ae993 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -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