From 5fd7da8ef50eeed0746673da36ceddf38d4ee84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20I=C3=B1iguez=20Goia?= Date: Fri, 13 Oct 2023 23:51:37 +0200 Subject: [PATCH] ui,stats: improved rules deletion When selecting rules with CTRL+A it was not deleting all the rules. Besides rules with the name empty was sent to the daemon. Related: #1037 --- ui/opensnitch/dialogs/stats.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/opensnitch/dialogs/stats.py b/ui/opensnitch/dialogs/stats.py index 7b39363d..615c3a72 100644 --- a/ui/opensnitch/dialogs/stats.py +++ b/ui/opensnitch/dialogs/stats.py @@ -805,6 +805,9 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): return ret1 and ret2 def _del_rule(self, rule_name, node_addr): + if rule_name == None or node_addr == None: + print("_del_rule() invalid parameters") + return nid, noti = self._nodes.delete_rule(rule_name, node_addr, self._notification_callback) if nid == None: return @@ -1236,9 +1239,10 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): self._notifications_sent[nid] = noti elif cur_idx == self.TAB_RULES and not self.fwTable.isVisible(): - for idx in selection: - name = model.index(idx.row(), self.COL_R_NAME).data() - node = model.index(idx.row(), self.COL_R_NODE).data() + selection = self.TABLES[cur_idx]['view'].copySelection() + for row in selection: + name = row[self.COL_R_NAME] + node = row[self.COL_R_NODE] self._del_rule(name, node) elif cur_idx == self.TAB_HOSTS or cur_idx == self.TAB_PROCS or cur_idx == self.TAB_ADDRS or \ cur_idx == self.TAB_USERS or cur_idx == self.TAB_PORTS: