Don't assume QCoreApplication::applicationName() will never change
Tests will typically create multiple QCoreApplications, some of them with different argv[0] than others, so we can't use a static variable to keep the cached application name. Change-Id: Icd97527730558944473a71373326b4a82f1b7cf7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
1749bab565
commit
f04b46f34e
@ -146,15 +146,17 @@ QString QCoreApplicationPrivate::macMenuBarName()
|
||||
#endif
|
||||
QString QCoreApplicationPrivate::appName() const
|
||||
{
|
||||
static QString applName;
|
||||
if (applicationName.isNull()) {
|
||||
#ifdef Q_OS_MAC
|
||||
applName = macMenuBarName();
|
||||
applicationName = macMenuBarName();
|
||||
#endif
|
||||
if (applName.isEmpty() && argv[0]) {
|
||||
char *p = strrchr(argv[0], '/');
|
||||
applName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
|
||||
if (applicationName.isEmpty() && argv[0]) {
|
||||
char *p = strrchr(argv[0], '/');
|
||||
applicationName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
|
||||
}
|
||||
}
|
||||
return applName;
|
||||
|
||||
return applicationName;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
~QCoreApplicationPrivate();
|
||||
|
||||
QString appName() const;
|
||||
mutable QString applicationName;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
static QString macMenuBarName();
|
||||
|
Loading…
Reference in New Issue
Block a user