QLockFile: don't use QCoreApplication::applicationName()
That was stupid for two reasons. First, applicationName() can be changed by the user by calling QCoreApplication::setApplicationName(), so if that happens, we won't be able to properly identify a lock belonging to a given application because the name changed. Second, because applicationName() is not what we compare to. Instead, let's use processNameByPid() on both content creation and verification. [ChangeLog][QtCore][QLockFile] Fixed a bug that would cause QLockFile mis-identify valid lock files as stale if the application name was set with QCoreApplication::setApplicationName(). Change-Id: I0b48fc8e90304e0dacc3fffd14e912a5c98c87e7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
4dca0cba30
commit
db1027bc36
@ -330,7 +330,7 @@ QByteArray QLockFilePrivate::lockFileContents() const
|
||||
{
|
||||
// Use operator% from the fast builder to avoid multiple memory allocations.
|
||||
return QByteArray::number(QCoreApplication::applicationPid()) % '\n'
|
||||
% QCoreApplication::applicationName().toUtf8() % '\n'
|
||||
% processNameByPid(QCoreApplication::applicationPid()).toUtf8() % '\n'
|
||||
% machineName().toUtf8() % '\n';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user