diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-09-30 00:20:53 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-10-06 01:53:53 +0000 |
commit | db1027bc360cb86526d95dd0d7f36107a4d36b47 (patch) | |
tree | 0a54b97fbdc82a19959086c8020035f05ebbad65 | |
parent | 4dca0cba304d18d19ec54df7dac719799279bc18 (diff) |
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>
-rw-r--r-- | src/corelib/io/qlockfile.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp index 197b1f80e5..129cf01b63 100644 --- a/src/corelib/io/qlockfile.cpp +++ b/src/corelib/io/qlockfile.cpp @@ -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'; } |