mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-03 19:07:11 -04:00
Make QElapsedTimer optional in QLockFile.
This restores compatibility with Qt 4.6.
This commit is contained in:
parent
826cd472c8
commit
8325b20d36
1 changed files with 10 additions and 3 deletions
|
@ -33,8 +33,11 @@
|
||||||
|
|
||||||
#include "qlockfile.h"
|
#include "qlockfile.h"
|
||||||
#include "qlockfile_p.h"
|
#include "qlockfile_p.h"
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
||||||
#include <QElapsedTimer>
|
# include <QElapsedTimer>
|
||||||
|
#else
|
||||||
|
# include <QTime>
|
||||||
|
#endif
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -199,7 +202,11 @@ bool QLockFile::lock()
|
||||||
bool QLockFile::tryLock(int timeout)
|
bool QLockFile::tryLock(int timeout)
|
||||||
{
|
{
|
||||||
Q_D(QLockFile);
|
Q_D(QLockFile);
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
|
#else
|
||||||
|
QTime timer;
|
||||||
|
#endif
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
timer.start();
|
timer.start();
|
||||||
int sleepTime = 100;
|
int sleepTime = 100;
|
||||||
|
@ -224,7 +231,7 @@ bool QLockFile::tryLock(int timeout)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (timeout == 0 || (timeout > 0 && timer.hasExpired(timeout)))
|
if (timeout == 0 || (timeout > 0 && (timer.elapsed() > timeout)))
|
||||||
return false;
|
return false;
|
||||||
QLockFileThread::msleep(sleepTime);
|
QLockFileThread::msleep(sleepTime);
|
||||||
if (sleepTime < 5 * 1000)
|
if (sleepTime < 5 * 1000)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue