QtSingleApplication: Fix unreliable '-client' option

QLockFile documention states:

  When protecting a resource over a long time, however, the
  application should always call setStaleLockTime(0ms) and then
  tryLock() with a short timeout.

Without the 0ms stale lock time the new Qt Creator instance would think
that the lockfile is stale and starts a new instance!

Amends dd1c9d1b71

Fixes: QTCREATORBUG-30624
Change-Id: I0c0166239242895e25c7bf05d59a371cd0295758
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Cristian Adam
2024-05-24 20:09:46 +02:00
parent 07b5c96194
commit d2cb8f0ccb

View File

@@ -60,6 +60,7 @@ QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId)
+ QLatin1Char('/') + socketName
+ QLatin1String("-lockfile");
lockFile.reset(new QLockFile(lockName));
lockFile->setStaleLockTime(0);
}
bool QtLocalPeer::isClient()