Commit 0cc0c32c authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Readability

No need to instantiate a process
Properly warn when something didn't work
parent e3b3e039
......@@ -677,20 +677,15 @@ void KSMServer::slotAutoStart()
return;
}
KService service(serviceName);
qCInfo(KSMSERVER) << "Starting autostart service " << serviceName;
auto p = new KProcess(this);
auto arguments = KIO::DesktopExecParser(service, QList<QUrl>()).resultingArguments();
if (arguments.isEmpty()) {
qCInfo(KSMSERVER) << "failed to parse" << serviceName << "for autostart";
qCWarning(KSMSERVER) << "failed to parse" << serviceName << "for autostart";
continue;
}
qCInfo(KSMSERVER) << "Starting autostart service " << serviceName << arguments;
auto program = arguments.takeFirst();
p->setProgram(program, arguments);
p->start();
connect(p, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [p](int exitCode) {
qCInfo(KSMSERVER) << "autostart service" << p->program() << "finished with exit code " << exitCode;
p->deleteLater();
});
if (!QProcess::startDetached(program, arguments))
qCWarning(KSMSERVER) << "could not start" << serviceName << ":" << program << arguments;
} while (true);
// Loop till we find a service that we can start.
}
......
Markdown is supported
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