diff options
Diffstat (limited to 'src/corelib/io/qlockfile_win.cpp')
-rw-r--r-- | src/corelib/io/qlockfile_win.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 77cdf66694..46a6b9da5e 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -167,21 +167,24 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) void QLockFile::unlock() { Q_D(QLockFile); - if (!d->isLocked) + if (!d->isLocked) return; - CloseHandle(d->fileHandle); - int attempts = 0; - static const int maxAttempts = 500; // 500ms - while (!QFile::remove(d->fileName) && ++attempts < maxAttempts) { - // Someone is reading the lock file right now (on Windows this prevents deleting it). - QThread::msleep(1); - } - if (attempts == maxAttempts) { - qWarning() << "Could not remove our own lock file" << d->fileName << ". Either other users of the lock file are reading it constantly for 500 ms, or we (no longer) have permissions to delete the file"; - // This is bad because other users of this lock file will now have to wait for the stale-lock-timeout... - } - d->lockError = QLockFile::NoError; - d->isLocked = false; + CloseHandle(d->fileHandle); + int attempts = 0; + static const int maxAttempts = 500; // 500ms + while (!QFile::remove(d->fileName) && ++attempts < maxAttempts) { + // Someone is reading the lock file right now (on Windows this prevents deleting it). + QThread::msleep(1); + } + if (attempts == maxAttempts) { + qWarning() << "Could not remove our own lock file" << d->fileName + << ". Either other users of the lock file are reading it constantly for 500 ms, " + "or we (no longer) have permissions to delete the file"; + // This is bad because other users of this lock file will now have to wait for the + // stale-lock-timeout... + } + d->lockError = QLockFile::NoError; + d->isLocked = false; } QT_END_NAMESPACE |