From be86147ad7d6b9b01291d25fcff6f5288a665feb Mon Sep 17 00:00:00 2001 From: Guy Freeman Date: Tue, 31 Mar 2026 21:10:41 +0300 Subject: [PATCH 1/3] ManagerDeviceList: Guard double-click against duplicate operations Co-Authored-By: Claude Opus 4.6 (1M context) --- blueman/gui/manager/ManagerDeviceList.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/blueman/gui/manager/ManagerDeviceList.py b/blueman/gui/manager/ManagerDeviceList.py index 2514a6ec6..561c6de14 100644 --- a/blueman/gui/manager/ManagerDeviceList.py +++ b/blueman/gui/manager/ManagerDeviceList.py @@ -242,6 +242,8 @@ def _on_event_clicked(self, _widget: Gtk.Widget, event: Gdk.Event) -> bool: if event.type == Gdk.EventType._2BUTTON_PRESS and cast(Gdk.EventButton, event).button == 1: if self.menu.show_generic_connect_calc(row["device"]['UUIDs']): + if self.menu.get_op(row["device"]): + return False if row["connected"]: self.menu.disconnect_service(row["device"]) elif Adapter(obj_path=row["device"]["Adapter"])["Powered"]: From 904dd57c116d4f804094798e9c27691326c14c50 Mon Sep 17 00:00:00 2001 From: Guy Freeman Date: Sat, 18 Apr 2026 21:14:38 +0300 Subject: [PATCH 2/3] ManagerDeviceList: Move guard earlier in _on_event_clicked Hoist the in-progress operation check out of the nested double-click branch to right after self.menu is ensured. Besides addressing review feedback and flattening one level of nesting (so SonarCloud is happy about maintainability), the guard now also covers the right-click popup path, which should not appear mid-operation either. Co-Authored-By: Claude Opus 4.7 (1M context) --- blueman/gui/manager/ManagerDeviceList.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blueman/gui/manager/ManagerDeviceList.py b/blueman/gui/manager/ManagerDeviceList.py index 561c6de14..da09a9469 100644 --- a/blueman/gui/manager/ManagerDeviceList.py +++ b/blueman/gui/manager/ManagerDeviceList.py @@ -240,10 +240,11 @@ def _on_event_clicked(self, _widget: Gtk.Widget, event: Gdk.Event) -> bool: if self.menu is None: self.menu = ManagerDeviceMenu(self.Blueman) + if self.menu.get_op(row["device"]): + return False + if event.type == Gdk.EventType._2BUTTON_PRESS and cast(Gdk.EventButton, event).button == 1: if self.menu.show_generic_connect_calc(row["device"]['UUIDs']): - if self.menu.get_op(row["device"]): - return False if row["connected"]: self.menu.disconnect_service(row["device"]) elif Adapter(obj_path=row["device"]["Adapter"])["Powered"]: From 4227828ce90e8dd3217ce0572e6e4cd453af761a Mon Sep 17 00:00:00 2001 From: Guy Freeman Date: Sat, 18 Apr 2026 21:28:59 +0300 Subject: [PATCH 3/3] ManagerDeviceList: Drop redundant else after guard return Cognitive complexity of _on_event_clicked is one point over SonarCloud's threshold; the else-branch after the posdata guard return is the obvious redundancy. Equivalent behavior, one less complexity point. Co-Authored-By: Claude Opus 4.7 (1M context) --- blueman/gui/manager/ManagerDeviceList.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/blueman/gui/manager/ManagerDeviceList.py b/blueman/gui/manager/ManagerDeviceList.py index da09a9469..67dbc3c89 100644 --- a/blueman/gui/manager/ManagerDeviceList.py +++ b/blueman/gui/manager/ManagerDeviceList.py @@ -225,9 +225,8 @@ def _on_event_clicked(self, _widget: Gtk.Widget, event: Gdk.Event) -> bool: posdata = self.get_path_at_pos(int(cast(Gdk.EventButton, event).x), int(cast(Gdk.EventButton, event).y)) if posdata is None: return False - else: - path = posdata[0] - assert path is not None + path = posdata[0] + assert path is not None tree_iter = self.filter.get_iter(path) assert tree_iter is not None