From d1898403267893f20ecf56134dd9fd3b529dadd5 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 15 May 2025 15:30:30 -0600 Subject: [PATCH] [PATCH] applets/devicenotifier: fix pointless mount action BUG: 503999 Audio CD and blank CD/DVD/BD does not have storage access. So check this before add mount action for them. (cherry picked from commit 683b8c3d71781c4e821cd2f9ac93eb4f157bb6ea) Co-authored-by: Bohdan Onofriichuk Gbp-Pq: Name upstream_60859fa9_applets-devicenotifier-fix-pointless-mount-action.patch --- .../devicenotifier/plugin/actions/mountaction.cpp | 13 ++++++++++++- applets/devicenotifier/plugin/actions/mountaction.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/applets/devicenotifier/plugin/actions/mountaction.cpp b/applets/devicenotifier/plugin/actions/mountaction.cpp index 4df5c982..88d3d898 100644 --- a/applets/devicenotifier/plugin/actions/mountaction.cpp +++ b/applets/devicenotifier/plugin/actions/mountaction.cpp @@ -18,6 +18,8 @@ MountAction::MountAction(const QString &udi, QObject *parent) : ActionInterface(udi, parent) , m_stateMonitor(DevicesStateMonitor::instance()) + , m_supportsMTP(false) + , m_hasStorageAccess(false) { Solid::Device device(udi); @@ -39,6 +41,15 @@ MountAction::MountAction(const QString &udi, QObject *parent) m_supportsMTP = supportedProtocols.contains(QLatin1String("mtp")); + // It's possible for there to be no StorageAccess (e.g. MTP devices don't have one) + if (device.is()) { + Solid::StorageAccess *access = device.as(); + if (access) { + qCDebug(APPLETS::DEVICENOTIFIER) << "Mount action: have storage access"; + m_hasStorageAccess = true; + } + } + connect(m_stateMonitor.get(), &DevicesStateMonitor::stateChanged, this, &MountAction::updateIsValid); } @@ -67,7 +78,7 @@ void MountAction::triggered() bool MountAction::isValid() const { - return m_stateMonitor->isRemovable(m_udi) && !m_stateMonitor->isMounted(m_udi) && !m_supportsMTP; + return m_hasStorageAccess && m_stateMonitor->isRemovable(m_udi) && !m_stateMonitor->isMounted(m_udi) && !m_supportsMTP; } void MountAction::updateIsValid(const QString &udi) diff --git a/applets/devicenotifier/plugin/actions/mountaction.h b/applets/devicenotifier/plugin/actions/mountaction.h index c7f744f1..a76ee2f5 100644 --- a/applets/devicenotifier/plugin/actions/mountaction.h +++ b/applets/devicenotifier/plugin/actions/mountaction.h @@ -33,6 +33,7 @@ private Q_SLOTS: private: bool m_supportsMTP; + bool m_hasStorageAccess; std::shared_ptr m_stateMonitor; }; -- 2.30.2