From 461d034e6ab4e07b6e3305381dc1fdb563a25769 Mon Sep 17 00:00:00 2001 From: ComixHe Date: Thu, 9 May 2024 16:28:07 +0800 Subject: [PATCH] fix: try to activate dialog service before init manager In linglong container, application couldn't find binary `dde-desktop`, and `com.deepin.filemanager.filedialog` may not be activated. So we use the `D-Bus Activation` mechanism to activate this service. Issue: https://github.com/linuxdeepin/developer-center/issues/8433 Signed-off-by: ComixHe --- platformthemeplugin/qdeepinfiledialoghelper.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/platformthemeplugin/qdeepinfiledialoghelper.cpp b/platformthemeplugin/qdeepinfiledialoghelper.cpp index 03d2f598..be516372 100644 --- a/platformthemeplugin/qdeepinfiledialoghelper.cpp +++ b/platformthemeplugin/qdeepinfiledialoghelper.cpp @@ -360,9 +360,18 @@ void QDeepinFileDialogHelper::initDBusFileDialogManager() } else { dialogService = DIALOG_SERVICE; } + + const auto *managerObjectPath = "/com/deepin/filemanager/filedialogmanager"; + auto conn = QDBusConnection::sessionBus(); + auto reply = conn.call(QDBusMessage::createMethodCall(dialogService, managerObjectPath , "org.freedesktop.DBus.Peer", "Ping")); + + if(reply.type() != QDBusMessage::ReplyMessage) { + qCWarning(fileDialogHelper) << reply.errorMessage(); + } + if (QDBusConnection::sessionBus().interface()->isServiceRegistered(dialogService).value() || !QStandardPaths::findExecutable("dde-desktop").isEmpty()) { - manager = new DFileDialogManager(dialogService, "/com/deepin/filemanager/filedialogmanager", QDBusConnection::sessionBus()); + manager = new DFileDialogManager(dialogService, managerObjectPath, QDBusConnection::sessionBus()); } }