From 8325b20d36b2950f752d23c9aad068e5804fc1e2 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Thu, 16 Jul 2015 21:52:08 +0200 Subject: [PATCH] Make QElapsedTimer optional in QLockFile. This restores compatibility with Qt 4.6. --- src/core/qlockfile.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/qlockfile.cpp b/src/core/qlockfile.cpp index 980f8ed85..567440c15 100644 --- a/src/core/qlockfile.cpp +++ b/src/core/qlockfile.cpp @@ -33,8 +33,11 @@ #include "qlockfile.h" #include "qlockfile_p.h" - -#include +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) +# include +#else +# include +#endif #include QT_BEGIN_NAMESPACE @@ -199,7 +202,11 @@ bool QLockFile::lock() bool QLockFile::tryLock(int timeout) { Q_D(QLockFile); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) QElapsedTimer timer; +#else + QTime timer; +#endif if (timeout > 0) timer.start(); int sleepTime = 100; @@ -224,7 +231,7 @@ bool QLockFile::tryLock(int timeout) } break; } - if (timeout == 0 || (timeout > 0 && timer.hasExpired(timeout))) + if (timeout == 0 || (timeout > 0 && (timer.elapsed() > timeout))) return false; QLockFileThread::msleep(sleepTime); if (sleepTime < 5 * 1000)