QCoreApplication::applicationDirPath/Linux: use /proc/self

There's no need to format our PID there if /proc/self exists and is a
link to the current process.

Drive-by replace with QStringLiteral, since we won't do any formatting
anyway.

Change-Id: I7a386ad4f0cb4e2ba629fffd1678fbf0a484ea69
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
Thiago Macieira 2021-04-24 20:24:36 -07:00
parent e1c1558218
commit f3446acbcd

View File

@ -2336,7 +2336,7 @@ QString QCoreApplication::applicationFilePath()
# if defined(Q_OS_LINUX) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_EMBEDDED))
// Try looking for a /proc/<pid>/exe symlink first which points to
// the absolute path of the executable
QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid()));
QFileInfo pfi(QStringLiteral("/proc/self/exe"));
if (pfi.exists() && pfi.isSymLink()) {
QCoreApplicationPrivate::setApplicationFilePath(pfi.canonicalFilePath());
return *QCoreApplicationPrivate::cachedApplicationFilePath;