QLockFile: use QCoreApplication::applicationName.

Unlike qAppName, it doesn't require a QCoreApplication instance,
making QLockFile usable in destructors of global statics.
This also uses the value passed to setApplicationName if called
rather than always argv[0].

Change-Id: I40446aba410db42d7cfe6b4408878faf435246f7
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2015-02-22 20:02:29 +01:00
parent 0d5ffd67a4
commit 88851fb3b0
2 changed files with 2 additions and 2 deletions

View File

@ -137,7 +137,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
// (otherwise we'd have to check every write call)
// Use operator% from the fast builder to avoid multiple memory allocations.
QByteArray fileData = QByteArray::number(QCoreApplication::applicationPid()) % '\n'
% qAppName().toUtf8() % '\n'
% QCoreApplication::applicationName().toUtf8() % '\n'
% localHostName() % '\n';
const QByteArray lockFileName = QFile::encodeName(fileName);

View File

@ -94,7 +94,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
QByteArray fileData;
fileData += QByteArray::number(QCoreApplication::applicationPid());
fileData += '\n';
fileData += qAppName().toUtf8();
fileData += QCoreApplication::applicationName().toUtf8();
fileData += '\n';
fileData += localHostName();
fileData += '\n';