diff --git a/krunner/main.cpp b/krunner/main.cpp --- a/krunner/main.cpp +++ b/krunner/main.cpp @@ -85,19 +85,11 @@ parser.process(app); 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"))) { return -1; } - KDBusService service(KDBusService::Unique); + KDBusService service(KDBusService::Unique | KDBusService::StartupOption(parser.isSet(replaceOption) ? KDBusService::Replace : 0)); QGuiApplication::setFallbackSessionManagementEnabled(false); diff --git a/shell/main.cpp b/shell/main.cpp --- a/shell/main.cpp +++ b/shell/main.cpp @@ -88,11 +88,11 @@ app.setQuitOnLastWindowClosed(false); - KSharedConfig::Ptr startupConf = KSharedConfig::openConfig(QStringLiteral("plasmashellrc")); KConfigGroup startupConfGroup(startupConf, "Shell"); const QString defaultShell = startupConfGroup.readEntry("ShellPackage", "org.kde.plasma.desktop"); + bool replace = false; { QCommandLineParser cliOptions; @@ -177,17 +177,6 @@ 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]() { //scene graphs errors come from a thread //even though we process them in the main thread, app.exit could still process these events @@ -210,9 +199,10 @@ } app.exit(-1); }); + replace = cliOptions.isSet(replaceOption); } - KDBusService service(KDBusService::Unique); + KDBusService service(KDBusService::Unique | KDBusService::StartupOption(replace ? KDBusService::Replace : 0)); SoftwareRendererNotifier::notifyIfRelevant();