From e5d549552614f89dd73b29fc3ee4710f65bb1e57 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 20 Mar 2012 18:01:20 +0100 Subject: Make QCoreApplication::applicationName() default to argv[0] This makes it more useful in all the Qt apps that don't set it, given that it's used internally by QTemporaryFile, QTemporaryDir, QStandardPaths, QDBus, QAccessibleApplication, etc. Qt4 compatibility in the deprecated QDesktopServices is preserved, no fallback there. Change-Id: I584463507cf917a3720793c6bd45d07c60f8356c Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qcoreapplication.cpp') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 967ed447d5..3d09d858a3 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1943,7 +1943,9 @@ QString QCoreApplication::organizationDomain() using the empty constructor. This saves having to repeat this information each time a QSettings object is created. - \sa organizationName organizationDomain applicationVersion + If not set, the application name defaults to the executable name (since 5.0). + + \sa organizationName organizationDomain applicationVersion applicationFilePath */ void QCoreApplication::setApplicationName(const QString &application) { @@ -1951,6 +1953,15 @@ void QCoreApplication::setApplicationName(const QString &application) } QString QCoreApplication::applicationName() +{ + QString appname = coreappdata()->application; + if (appname.isEmpty() && QCoreApplication::self) + appname = QCoreApplication::self->d_func()->appName(); + return appname; +} + +// Exported for QDesktopServices (Qt4 behavior compatibility) +Q_CORE_EXPORT QString qt_applicationName_noFallback() { return coreappdata()->application; } -- cgit v1.2.3