diff --git a/src/core/qlockfile.cpp b/src/core/qlockfile.cpp index 980f8ed8..567440c1 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)