Modified breakpoint and watchpoint model to eliminate redundant break/watch points while adding. eric7

Mon, 04 Nov 2024 11:39:18 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 04 Nov 2024 11:39:18 +0100
branch
eric7
changeset 11037
adfda913834a
parent 11036
326ae637285d
child 11038
918bc08e1f89

Modified breakpoint and watchpoint model to eliminate redundant break/watch points while adding.

src/eric7/Debugger/BreakPointModel.py file | annotate | diff | comparison | revisions
src/eric7/Debugger/WatchPointModel.py file | annotate | diff | comparison | revisions
--- a/src/eric7/Debugger/BreakPointModel.py	Sun Nov 03 18:16:47 2024 +0100
+++ b/src/eric7/Debugger/BreakPointModel.py	Mon Nov 04 11:39:18 2024 +0100
@@ -272,10 +272,12 @@
         @type tuple of (str, bool, bool, int)
         """
         bp = [fn, line] + list(properties)
-        cnt = len(self.breakpoints)
-        self.beginInsertRows(QModelIndex(), cnt, cnt)
-        self.breakpoints.append(bp)
-        self.endInsertRows()
+        if bp not in self.breakpoints:
+            # add it only, if not present already
+            cnt = len(self.breakpoints)
+            self.beginInsertRows(QModelIndex(), cnt, cnt)
+            self.breakpoints.append(bp)
+            self.endInsertRows()
 
     def addBreakPoints(self, breakpoints):
         """
@@ -285,10 +287,14 @@
             condition, temporary flag, enabled flag and ignore count each
         @type list of (str, int, str, bool, bool, int)
         """
-        cnt = len(self.breakpoints)
-        self.beginInsertRows(QModelIndex(), cnt, cnt + len(breakpoints) - 1)
-        self.breakpoints += breakpoints
-        self.endInsertRows()
+        # eliminate redundant break points
+        newBreakpoints = [b for b in set(breakpoints) if b not in self.breakpoints]
+
+        if newBreakpoints:
+            cnt = len(self.breakpoints)
+            self.beginInsertRows(QModelIndex(), cnt, cnt + len(newBreakpoints) - 1)
+            self.breakpoints += newBreakpoints
+            self.endInsertRows()
 
     def setBreakPointByIndex(self, index, fn, line, properties):
         """
--- a/src/eric7/Debugger/WatchPointModel.py	Sun Nov 03 18:16:47 2024 +0100
+++ b/src/eric7/Debugger/WatchPointModel.py	Mon Nov 04 11:39:18 2024 +0100
@@ -232,10 +232,12 @@
         @type tuple of (bool, bool, int)
         """
         wp = [cond, special] + list(properties)
-        cnt = len(self.watchpoints)
-        self.beginInsertRows(QModelIndex(), cnt, cnt)
-        self.watchpoints.append(wp)
-        self.endInsertRows()
+        if wp not in self.watchpoints:
+            # add it only, if not present already
+            cnt = len(self.watchpoints)
+            self.beginInsertRows(QModelIndex(), cnt, cnt)
+            self.watchpoints.append(wp)
+            self.endInsertRows()
 
     def addWatchPoints(self, watchpoints):
         """
@@ -245,10 +247,14 @@
             condition, temporary flag, enabled flag and ignore count each
         @type list of (str, str, bool, bool, int)
         """
-        cnt = len(self.watchpoints)
-        self.beginInsertRows(QModelIndex(), cnt, cnt + len(watchpoints) - 1)
-        self.watchpoints += watchpoints
-        self.endInsertRows()
+        # eliminate redundant break points
+        newWatchpoints = [w for w in set(watchpoints) if w not in self.watchpoints]
+
+        if newWatchpoints:
+            cnt = len(self.watchpoints)
+            self.beginInsertRows(QModelIndex(), cnt, cnt + len(newWatchpoints) - 1)
+            self.watchpoints += newWatchpoints
+            self.endInsertRows()
 
     def setWatchPointByIndex(self, index, cond, special, properties):
         """

eric ide

mercurial