From f31a4efbeef6264da5fb6ca78eae251484e60c06 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 14 Feb 2021 13:14:37 +0000 Subject: [PATCH] Avoid tight loop on lock file access failure --- main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 0960789e0..2db250b33 100644 --- a/main.cpp +++ b/main.cpp @@ -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