Changeset View
Changeset View
Standalone View
Standalone View
src/kdbusservice.cpp
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 79 | { | |||
---|---|---|---|---|---|
89 | 89 | | |||
90 | if (bus) { | 90 | if (bus) { | ||
91 | d->serviceName = d->generateServiceName(); | 91 | d->serviceName = d->generateServiceName(); | ||
92 | QString objectPath = QLatin1Char('/') + d->serviceName; | 92 | QString objectPath = QLatin1Char('/') + d->serviceName; | ||
93 | objectPath.replace(QLatin1Char('.'), QLatin1Char('/')); | 93 | objectPath.replace(QLatin1Char('.'), QLatin1Char('/')); | ||
94 | objectPath.replace(QLatin1Char('-'), QLatin1Char('_')); // see spec change at https://bugs.freedesktop.org/show_bug.cgi?id=95129 | 94 | objectPath.replace(QLatin1Char('-'), QLatin1Char('_')); // see spec change at https://bugs.freedesktop.org/show_bug.cgi?id=95129 | ||
95 | 95 | | |||
96 | if (options & Multiple) { | 96 | if (options & Multiple) { | ||
97 | const QString pid = QString::number(QCoreApplication::applicationPid()); | 97 | bool inSandbox = false; | ||
98 | d->serviceName += QLatin1Char('-') + pid; | 98 | if (!qEnvironmentVariableIsEmpty("XDG_RUNTIME_DIR")) { | ||
dfaure: this if() seems useless (double lookup). You already get the value, and then you even check it… | |||||
99 | const QByteArray runtimeDir = qgetenv("XDG_RUNTIME_DIR"); | ||||
100 | if (!runtimeDir.isEmpty()) { | ||||
101 | inSandbox = QFileInfo::exists(QString::fromUtf8(runtimeDir) + QLatin1String("/flatpak-info")); | ||||
102 | } | ||||
103 | } | ||||
104 | | ||||
105 | if (inSandbox) | ||||
dfaure: KF5 coding style: { ... } even around single-line statements. | |||||
106 | d->serviceName += QStringLiteral(".kdbus-") + QDBusConnection::sessionBus().baseService().replace(QRegularExpression(QStringLiteral("[\\.:]")), QStringLiteral("_")); | ||||
107 | else | ||||
108 | d->serviceName += QLatin1Char('-') + QString::number(QCoreApplication::applicationPid()); | ||||
99 | } | 109 | } | ||
100 | 110 | | |||
101 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/MainApplication"), QCoreApplication::instance(), | 111 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/MainApplication"), QCoreApplication::instance(), | ||
102 | QDBusConnection::ExportAllSlots | | 112 | QDBusConnection::ExportAllSlots | | ||
103 | QDBusConnection::ExportScriptableProperties | | 113 | QDBusConnection::ExportScriptableProperties | | ||
104 | QDBusConnection::ExportAdaptors); | 114 | QDBusConnection::ExportAdaptors); | ||
105 | QDBusConnection::sessionBus().registerObject(objectPath, this, | 115 | QDBusConnection::sessionBus().registerObject(objectPath, this, | ||
106 | QDBusConnection::ExportAdaptors); | 116 | QDBusConnection::ExportAdaptors); | ||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |
this if() seems useless (double lookup). You already get the value, and then you even check it for empty.