Add function to access QLockFile's file name
This is useful in cases like error handling when you need to print the name of the lock file. Change-Id: Ife4901ed53ae81d19e68cce7f1c173ef3745d56f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
9402a351dd
commit
927cd268aa
@ -150,6 +150,14 @@ QLockFile::~QLockFile()
|
||||
unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the file name of the lock file
|
||||
*/
|
||||
QString QLockFile::fileName() const
|
||||
{
|
||||
return d_ptr->fileName;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets \a staleLockTime to be the time in milliseconds after which
|
||||
a lock file is considered stale.
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
QLockFile(const QString &fileName);
|
||||
~QLockFile();
|
||||
|
||||
QString fileName() const;
|
||||
|
||||
bool lock();
|
||||
bool tryLock(int timeout = 0);
|
||||
void unlock();
|
||||
|
@ -96,6 +96,7 @@ void tst_QLockFile::lockUnlock()
|
||||
const QString fileName = dir.path() + "/lock1";
|
||||
QVERIFY(!QFile(fileName).exists());
|
||||
QLockFile lockFile(fileName);
|
||||
QCOMPARE(lockFile.fileName(), fileName);
|
||||
QVERIFY(lockFile.lock());
|
||||
QVERIFY(lockFile.isLocked());
|
||||
QCOMPARE(int(lockFile.error()), int(QLockFile::NoError));
|
||||
|
Loading…
Reference in New Issue
Block a user