Verified Commit d2dabf12 authored by Fushan Wen's avatar Fushan Wen
Browse files

startkde: fix a condition error in `allServices`

`startsWith` in QStringList only checks if the first item is equal to
the value, which does not match the prefix.
parent 9dad1864
Pipeline #174435 passed with stage
in 8 minutes and 3 seconds
......@@ -55,25 +55,13 @@ void messageBox(const QString &text)
QStringList allServices(const QLatin1String &prefix)
{
QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface();
const QStringList services = bus->registeredServiceNames();
QMap<QString, QStringList> servicesWithAliases;
const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames();
QStringList names;
for (const QString &serviceName : services) {
QDBusReply<QString> reply = bus->serviceOwner(serviceName);
QString owner = reply;
if (owner.isEmpty())
owner = serviceName;
servicesWithAliases[owner].append(serviceName);
}
std::copy_if(services.cbegin(), services.cend(), std::back_inserter(names), [&prefix](const QString &serviceName) {
return serviceName.startsWith(prefix);
});
QStringList names;
for (auto it = servicesWithAliases.constBegin(); it != servicesWithAliases.constEnd(); ++it) {
if (it.value().startsWith(prefix))
names << it.value();
}
names.removeDuplicates();
names.sort();
return names;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment