generic: call QCoreApplication::applicationName() as static method

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-19 01:12:54 +03:00
parent f2badd9016
commit e5f56675d2
7 changed files with 15 additions and 18 deletions

View file

@ -168,7 +168,6 @@ KStandardDirs *KComponentData::dirs() const
{ {
Q_ASSERT(d); Q_ASSERT(d);
d->lazyInit(*this); d->lazyInit(*this);
return d->dirs; return d->dirs;
} }
@ -176,7 +175,6 @@ const KSharedConfig::Ptr &KComponentData::config() const
{ {
Q_ASSERT(d); Q_ASSERT(d);
d->lazyInit(*this); d->lazyInit(*this);
return d->sharedConfig; return d->sharedConfig;
} }

View file

@ -31,7 +31,7 @@ class KComponentDataPrivate
{ {
public: public:
KComponentDataPrivate(const KAboutData &aboutData_) KComponentDataPrivate(const KAboutData &aboutData_)
: dirs(0), : dirs(nullptr),
aboutData(aboutData_), aboutData(aboutData_),
refCount(1) refCount(1)
{ {
@ -40,7 +40,7 @@ public:
shouldRemoveCatalog = true; shouldRemoveCatalog = true;
} else { } else {
shouldRemoveCatalog = false; shouldRemoveCatalog = false;
} }
} }
~KComponentDataPrivate() ~KComponentDataPrivate()

View file

@ -53,8 +53,8 @@ class KGlobalPrivate
{ {
public: public:
inline KGlobalPrivate() inline KGlobalPrivate()
: locale(0), : locale(nullptr),
charsets(0), charsets(nullptr),
localeIsFromFakeComponent(false) localeIsFromFakeComponent(false)
{ {
// the umask is read here before any threads are created to avoid race conditions // the umask is read here before any threads are created to avoid race conditions
@ -66,9 +66,9 @@ class KGlobalPrivate
inline ~KGlobalPrivate() inline ~KGlobalPrivate()
{ {
delete locale; delete locale;
locale = 0; locale = nullptr;
delete charsets; delete charsets;
charsets = 0; charsets = nullptr;
} }
KComponentData activeComponent; KComponentData activeComponent;
@ -275,10 +275,9 @@ QString KGlobal::caption()
} else if (d->mainComponent.isValid() && d->mainComponent.aboutData()) { } else if (d->mainComponent.isValid() && d->mainComponent.aboutData()) {
// We have some about data ? // We have some about data ?
return d->mainComponent.aboutData()->programName(); return d->mainComponent.aboutData()->programName();
} else {
// Last resort : application name
return QCoreApplication::instance()->applicationName();
} }
// Last resort : application name
return QCoreApplication::applicationName();
} }
/** /**

View file

@ -215,7 +215,7 @@ void KToolInvocation::invokeHelp(const QString &anchor,
QString appname; QString appname;
QString docPath; QString docPath;
if (_appname.isEmpty()) { if (_appname.isEmpty()) {
appname = QCoreApplication::instance()->applicationName(); appname = QCoreApplication::applicationName();
} else { } else {
appname = _appname; appname = _appname;
} }

View file

@ -119,7 +119,7 @@ KAction *create(StandardAction id, const QObject *recvr, const char *slot, QObje
else else
aboutData = KGlobal::aboutData(); aboutData = KGlobal::aboutData();
*/ */
QString appName = (aboutData) ? aboutData->programName() : qApp->applicationName(); QString appName = (aboutData) ? aboutData->programName() : QCoreApplication::applicationName();
sLabel = i18n( pInfo->psLabel, appName ); sLabel = i18n( pInfo->psLabel, appName );
} }
break; break;

View file

@ -292,7 +292,7 @@ QString KApplicationPrivate::sessionConfigName() const
QString sessKey = q->sessionKey(); QString sessKey = q->sessionKey();
if ( sessKey.isEmpty() && !sessionKey.isEmpty() ) if ( sessKey.isEmpty() && !sessionKey.isEmpty() )
sessKey = sessionKey; sessKey = sessionKey;
return QString::fromLatin1("session/%1_%2_%3").arg(q->applicationName()).arg(q->sessionId()).arg(sessKey); return QString::fromLatin1("session/%1_%2_%3").arg(QCoreApplication::applicationName()).arg(q->sessionId()).arg(sessKey);
} }
#ifdef Q_WS_X11 #ifdef Q_WS_X11
@ -440,7 +440,7 @@ void KApplicationPrivate::init()
reversedDomain.prepend(s); reversedDomain.prepend(s);
} }
const QString pidSuffix = QString::number( getpid() ).prepend( QLatin1String("-") ); const QString pidSuffix = QString::number( getpid() ).prepend( QLatin1String("-") );
const QString serviceName = reversedDomain + q->applicationName() + pidSuffix; const QString serviceName = reversedDomain + QCoreApplication::applicationName() + pidSuffix;
if ( bus->registerService(serviceName) == QDBusConnectionInterface::ServiceNotRegistered ) { if ( bus->registerService(serviceName) == QDBusConnectionInterface::ServiceNotRegistered ) {
kError() << "Couldn't register name '" << serviceName << "' with DBUS - another process owns it already!"; kError() << "Couldn't register name '" << serviceName << "' with DBUS - another process owns it already!";
::exit(126); ::exit(126);
@ -456,7 +456,7 @@ void KApplicationPrivate::init()
KSharedConfig::Ptr config = componentData.config(); KSharedConfig::Ptr config = componentData.config();
QByteArray readOnly = qgetenv("KDE_HOME_READONLY"); QByteArray readOnly = qgetenv("KDE_HOME_READONLY");
if (readOnly.isEmpty() && q->applicationName() != QLatin1String("kdialog")) if (readOnly.isEmpty() && QCoreApplication::applicationName() != QLatin1String("kdialog"))
{ {
config->isConfigWritable(true); config->isConfigWritable(true);
} }
@ -477,7 +477,7 @@ void KApplicationPrivate::init()
// HACK: KLauncher creates KApplication instance and KToolInvocation creates KLauncher instance // HACK: KLauncher creates KApplication instance and KToolInvocation creates KLauncher instance
// (i.e recursion) // (i.e recursion)
if (q->applicationName() != QLatin1String("klauncher")) { if (QCoreApplication::applicationName() != QLatin1String("klauncher")) {
q->connect( q->connect(
KToolInvocation::self(), SIGNAL(kapplication_hook(QStringList&,QByteArray&)), KToolInvocation::self(), SIGNAL(kapplication_hook(QStringList&,QByteArray&)),
q, SLOT(_k_KToolInvocation_hook(QStringList&,QByteArray&)) q, SLOT(_k_KToolInvocation_hook(QStringList&,QByteArray&))

View file

@ -352,7 +352,7 @@ void KMainWindowPrivate::polish(KMainWindow *q)
q->winId(); // workaround for setWindowRole() crashing, and set also window role, just in case TT q->winId(); // workaround for setWindowRole() crashing, and set also window role, just in case TT
q->setWindowRole( s ); // will keep insisting that object name suddenly should not be used for window role q->setWindowRole( s ); // will keep insisting that object name suddenly should not be used for window role
dbusName = '/' + qApp->applicationName() + '/' + q->objectName().replace(QLatin1Char('/'), QLatin1Char('_')); dbusName = '/' + QCoreApplication::applicationName() + '/' + q->objectName().replace(QLatin1Char('/'), QLatin1Char('_'));
// Clean up for dbus usage: any non-alphanumeric char should be turned into '_' // Clean up for dbus usage: any non-alphanumeric char should be turned into '_'
const int len = dbusName.length(); const int len = dbusName.length();
for ( int i = 0; i < len; ++i ) { for ( int i = 0; i < len; ++i ) {