Avoid tight loop on lock file access failure

This commit is contained in:
Bill Somerville 2021-02-14 13:14:37 +00:00
parent dacd534284
commit f31a4efbee
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
1 changed files with 5 additions and 2 deletions

View File

@ -225,8 +225,7 @@ int main(int argc, char *argv[])
// disallow multiple instances with same instance key
QLockFile instance_lock {temp_dir.absoluteFilePath (a.applicationName () + ".lock")};
instance_lock.setStaleLockTime (0);
bool lock_ok {false};
while (!(lock_ok = instance_lock.tryLock ()))
while (!instance_lock.tryLock ())
{
if (QLockFile::LockFailedError == instance_lock.error ())
{
@ -249,6 +248,10 @@ int main(int argc, char *argv[])
throw std::runtime_error {"Multiple instances must have unique rig names"};
}
}
else
{
throw std::runtime_error {"Failed to access lock file"};
}
}
// load UI translations