diff options
author | David Faure <david.faure@kdab.com> | 2015-03-29 22:09:56 +0200 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2015-05-09 10:01:33 +0000 |
commit | f1bfc4266bb0b4a3269d79f6ed34eaa8a1cadbca (patch) | |
tree | 937313ca7d44a4f676f9e147ebf283fd32c13163 /src/corelib/kernel/qcoreapplication.cpp | |
parent | 1ac1ae05f551d45772ff2a840dba128abf04171e (diff) |
Don't overwrite applicationName if already set.
My commit 6c973dee2cb1686ea32657 broke the case where setApplicationName
is called before the QCoreApplication constructor.
Fixed and added autotest.
Task-number: QTBUG-45283
Change-Id: If7bdb0d82be50b50a95a04027f5f9d7143c1a7ac
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index fffecbfb55..b6f839d554 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -326,6 +326,7 @@ struct QCoreApplicationData { #ifndef QT_NO_LIBRARY app_libpaths = 0; #endif + applicationNameSet = false; } ~QCoreApplicationData() { #ifndef QT_NO_LIBRARY @@ -370,8 +371,8 @@ struct QCoreApplicationData { QString orgName, orgDomain; QString application; // application name, initially from argv[0], can then be modified. - QString applicationNameCompat; // for QDesktopServices. Only set explicitly. QString applicationVersion; + bool applicationNameSet; // true if setApplicationName was called #ifndef QT_NO_LIBRARY QStringList *app_libpaths; @@ -753,7 +754,8 @@ void QCoreApplication::init() QCoreApplication::self = this; // Store app name (so it's still available after QCoreApplication is destroyed) - coreappdata()->application = d_func()->appName(); + if (!coreappdata()->applicationNameSet) + coreappdata()->application = d_func()->appName(); QLoggingRegistry::instance()->init(); @@ -2350,13 +2352,13 @@ QString QCoreApplication::organizationDomain() */ void QCoreApplication::setApplicationName(const QString &application) { + coreappdata()->applicationNameSet = !application.isEmpty(); QString newAppName = application; if (newAppName.isEmpty() && QCoreApplication::self) newAppName = QCoreApplication::self->d_func()->appName(); if (coreappdata()->application == newAppName) return; coreappdata()->application = newAppName; - coreappdata()->applicationNameCompat = newAppName; #ifndef QT_NO_QOBJECT if (QCoreApplication::self) emit QCoreApplication::self->applicationNameChanged(); @@ -2374,7 +2376,7 @@ QString QCoreApplication::applicationName() // Exported for QDesktopServices (Qt4 behavior compatibility) Q_CORE_EXPORT QString qt_applicationName_noFallback() { - return coreappdata()->applicationNameCompat; + return coreappdata()->applicationNameSet ? coreappdata()->application : QString(); } /*! |