]> git.lyx.org Git - features.git/commit
Fix Qt deprecation warns for QTime
authorScott Kostyshak <skostysh@lyx.org>
Mon, 16 Mar 2020 00:32:16 +0000 (20:32 -0400)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:54 +0000 (15:48 +0200)
commit75d8a4b9eb73374338da63678418178551263f80
treea1502e39a216efd35677fa0b81eabcae0d7cdfd7
parentc1301b13be1468ddf973bb0f57b887fa0c873f25
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
src/support/Systemcall.cpp