Commit 569a303b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Let KDBusService deal with the replace option

Summary: Depends on D22946

Test Plan: Replaced my plasmashell and krunner processes

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D22967
parent a4e18e2b
...@@ -85,19 +85,11 @@ int main(int argc, char **argv) ...@@ -85,19 +85,11 @@ int main(int argc, char **argv)
parser.process(app); parser.process(app);
aboutData.processCommandLine(&parser); aboutData.processCommandLine(&parser);
if (parser.isSet(replaceOption)) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.krunner"),
QStringLiteral("/MainApplication"),
QStringLiteral("org.qtproject.Qt.QCoreApplication"),
QStringLiteral("quit"));
QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits
}
if (!KAuthorized::authorize(QStringLiteral("run_command"))) { if (!KAuthorized::authorize(QStringLiteral("run_command"))) {
return -1; return -1;
} }
KDBusService service(KDBusService::Unique); KDBusService service(KDBusService::Unique | KDBusService::StartupOption(parser.isSet(replaceOption) ? KDBusService::Replace : 0));
QGuiApplication::setFallbackSessionManagementEnabled(false); QGuiApplication::setFallbackSessionManagementEnabled(false);
......
...@@ -88,11 +88,11 @@ int main(int argc, char *argv[]) ...@@ -88,11 +88,11 @@ int main(int argc, char *argv[])
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
KSharedConfig::Ptr startupConf = KSharedConfig::openConfig(QStringLiteral("plasmashellrc")); KSharedConfig::Ptr startupConf = KSharedConfig::openConfig(QStringLiteral("plasmashellrc"));
KConfigGroup startupConfGroup(startupConf, "Shell"); KConfigGroup startupConfGroup(startupConf, "Shell");
const QString defaultShell = startupConfGroup.readEntry("ShellPackage", "org.kde.plasma.desktop"); const QString defaultShell = startupConfGroup.readEntry("ShellPackage", "org.kde.plasma.desktop");
bool replace = false;
{ {
QCommandLineParser cliOptions; QCommandLineParser cliOptions;
...@@ -177,17 +177,6 @@ int main(int argc, char *argv[]) ...@@ -177,17 +177,6 @@ int main(int argc, char *argv[])
qApp->setProperty("_plasma_dbus_master", true); qApp->setProperty("_plasma_dbus_master", true);
} }
if (cliOptions.isSet(replaceOption)) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"),
QStringLiteral("/MainApplication"),
QStringLiteral("org.qtproject.Qt.QCoreApplication"),
QStringLiteral("quit"));
auto reply = QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits
while (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.plasmashell"))) {
QCoreApplication::processEvents(QEventLoop::AllEvents);
}
}
QObject::connect(corona, &ShellCorona::glInitializationFailed, &app, [&app]() { QObject::connect(corona, &ShellCorona::glInitializationFailed, &app, [&app]() {
//scene graphs errors come from a thread //scene graphs errors come from a thread
//even though we process them in the main thread, app.exit could still process these events //even though we process them in the main thread, app.exit could still process these events
...@@ -210,9 +199,10 @@ int main(int argc, char *argv[]) ...@@ -210,9 +199,10 @@ int main(int argc, char *argv[])
} }
app.exit(-1); app.exit(-1);
}); });
replace = cliOptions.isSet(replaceOption);
} }
KDBusService service(KDBusService::Unique); KDBusService service(KDBusService::Unique | KDBusService::StartupOption(replace ? KDBusService::Replace : 0));
SoftwareRendererNotifier::notifyIfRelevant(); SoftwareRendererNotifier::notifyIfRelevant();
......
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