[PATCH] applets/devicenotifier: check if device has been added before
authorBohdan Onofriichuk <bogdan.onofriuchuk@gmail.com>
Mon, 5 May 2025 19:13:54 +0000 (19:13 +0000)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:31:26 +0000 (08:31 +0200)
BUG: 495140

Skip device if applet already has device with similar udi

Gbp-Pq: Name upstream_a83c4e5f_applets-devicenotifier-check-if-device-has-been-added-before.patch

applets/devicenotifier/plugin/devicecontrol.cpp

index 829027ce50cd882dec983bfa294358fa6a0edd46..1e8c7403ab153ecfe8f03b7de9e6779ee3e2db10 100644 (file)
@@ -152,6 +152,12 @@ QHash<int, QByteArray> DeviceControl::roleNames() const
 void DeviceControl::onDeviceAdded(const QString &udi)
 {
     qCDebug(APPLETS::DEVICENOTIFIER) << "Device Controller: Added device signal arrived : " << udi;
+
+    if (m_actions.contains(udi)) {
+        qCDebug(APPLETS::DEVICENOTIFIER) << "Device Controller: Device already exists. Don't add another one : " << udi;
+        return;
+    }
+
     Solid::Device device(udi);
 
     if (!device.isValid()) {