From db1027bc360cb86526d95dd0d7f36107a4d36b47 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 30 Sep 2017 00:20:53 -0700 Subject: 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 Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/io/qlockfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'; } -- cgit v1.2.3