From d1fbf64011e1b664d403b0a748ba7d3c4fea0e47 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Tue, 1 Nov 2022 20:58:48 +0800 Subject: [PATCH] fix: proper check for filemanager1 dbus --- app/mainwindow.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index c7caa17..7e78ae9 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -38,6 +38,7 @@ #ifdef HAVE_QTDBUS #include +#include #endif // HAVE_QTDBUS MainWindow::MainWindow(QWidget *parent) @@ -748,13 +749,18 @@ void MainWindow::on_actionLocateInFileManager_triggered() QProcess::startDetached("explorer", QStringList() << "/select," << QDir::toNativeSeparators(fileInfo.absoluteFilePath())); #elif defined(Q_OS_LINUX) and defined(HAVE_QTDBUS) // Use https://www.freedesktop.org/wiki/Specifications/file-manager-interface/ if possible + const QDBusConnectionInterface * dbusIface = QDBusConnection::sessionBus().interface(); + if (!dbusIface || !dbusIface->isServiceRegistered(QLatin1String("org.freedesktop.FileManager1"))) { + QDesktopServices::openUrl(folderUrl); + return; + } QDBusInterface fm1Iface(QStringLiteral("org.freedesktop.FileManager1"), QStringLiteral("/org/freedesktop/FileManager1"), QStringLiteral("org.freedesktop.FileManager1")); - fm1Iface.setTimeout(500); + fm1Iface.setTimeout(1000); fm1Iface.callWithArgumentList(QDBus::Block, "ShowItems", { QStringList{currentFileUrl.toString()}, - QString::number(QDateTime::currentSecsSinceEpoch()) + QString() }); if (fm1Iface.lastError().isValid()) { QDesktopServices::openUrl(folderUrl);