From 9b45ce523325ab79101b06ada66e00dfbcde8492 Mon Sep 17 00:00:00 2001 From: PiliLily Date: Sat, 8 Aug 2026 11:36:31 +0000 Subject: [PATCH 1/2] fix(platform): preserve arguments in runCommand fallback Split the command line into a program and argv before using QProcess::startDetached when the process-manager D-Bus call fails, and report empty or failed fallback launches. Signed-off-by: PiliLily --- platform/ukui/app-launcher.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/ukui/app-launcher.cpp b/platform/ukui/app-launcher.cpp index 0da7145..38bc39d 100644 --- a/platform/ukui/app-launcher.cpp +++ b/platform/ukui/app-launcher.cpp @@ -210,7 +210,15 @@ void AppLauncher::runCommand(const QString &cmd) QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [cmd] (QDBusPendingCallWatcher *self) { if (self->isError()) { qWarning() << "Fail to call " << KYLIN_APP_MANAGER_INTERFACE << self->error(); - QProcess::startDetached(cmd, {}); + QStringList commandParts = QProcess::splitCommand(cmd); + if (commandParts.isEmpty()) { + qWarning() << "Fail to run empty command"; + } else { + const QString program = commandParts.takeFirst(); + if (!QProcess::startDetached(program, commandParts)) { + qWarning() << "Fail to run command" << cmd; + } + } } self->deleteLater(); }); -- Gitee From c805b66ef4d0286ef566f2e0055e53846ed819cf Mon Sep 17 00:00:00 2001 From: PiliLily Date: Sat, 8 Aug 2026 11:36:53 +0000 Subject: [PATCH 2/2] test(platform): cover runCommand fallback arguments Use a script path and argument containing spaces, then assert that the D-Bus failure fallback passes both argv entries unchanged to the detached process. Signed-off-by: PiliLily --- platform/autotest/test-app-launcher.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/autotest/test-app-launcher.cpp b/platform/autotest/test-app-launcher.cpp index ae449eb..39f08ff 100644 --- a/platform/autotest/test-app-launcher.cpp +++ b/platform/autotest/test-app-launcher.cpp @@ -392,18 +392,20 @@ void app_launcher_test::runCommandFallsBackToDetachedProcessWhenProcessManagerCa const QString markerPath = dir.filePath(QStringLiteral("run-command.marker")); const QByteArray scriptContents = "#!/bin/sh\n" - "printf fallback-run > \"" + markerPath.toUtf8() + "\"\n"; - const QString scriptPath = writeExecutableScript(dir, QStringLiteral("run-command.sh"), scriptContents); + "printf '%s\\n%s\\n' \"$1\" \"$2\" > \"" + markerPath.toUtf8() + "\"\n"; + const QString scriptPath = writeExecutableScript(dir, QStringLiteral("run command.sh"), scriptContents); QVERIFY(!scriptPath.isEmpty()); auto *launcher = AppLauncher::instance(); + const QString argumentWithSpaces = QStringLiteral("value with spaces"); + const QString command = QStringLiteral("\"%1\" --label \"%2\"").arg(scriptPath, argumentWithSpaces); - launcher->runCommand(scriptPath); + launcher->runCommand(command); QTRY_VERIFY(QFile::exists(markerPath)); QFile markerFile(markerPath); QVERIFY(markerFile.open(QIODevice::ReadOnly)); - QCOMPARE(QString::fromUtf8(markerFile.readAll()).trimmed(), QStringLiteral("fallback-run")); + QCOMPARE(QString::fromUtf8(markerFile.readAll()), QStringLiteral("--label\nvalue with spaces\n")); waitForNoPendingCallWatchers(launcher); } -- Gitee