Handling of no more existing items improved, e.g. list items which has as last child Variables Viewer

Sat, 27 Apr 2019 22:16:35 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 27 Apr 2019 22:16:35 +0200
branch
Variables Viewer
changeset 6979
c272ec33ea11
parent 6978
720247f98e1f
child 6980
cf9351b063a8

Handling of no more existing items improved, e.g. list items which has as last child
an open list.

eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
eric6/Debugger/VariablesViewer.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugClientBase.py	Sat Apr 27 22:06:38 2019 +0200
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Sat Apr 27 22:16:35 2019 +0200
@@ -1529,7 +1529,7 @@
                 else:
                     break
             
-            idx = -2
+            idx = -3  # Requested variable doesn't exist anymore
             # If found, get the details of attribute
             if variable is not None:
                 typeName, typeStr, resolver = DebugVariables.getType(variable)
--- a/eric6/Debugger/VariablesViewer.py	Sat Apr 27 22:06:38 2019 +0200
+++ b/eric6/Debugger/VariablesViewer.py	Sat Apr 27 22:16:35 2019 +0200
@@ -349,7 +349,16 @@
             row = parent.parent.childs.index(parent)
             parentIdx = self.createIndex(row, 0, parent)
         
-        if itemStartIndex == -2:
+        if itemStartIndex == -3:
+            # Item doesn't exist any more
+            parentIdx = self.parent(parentIdx)
+            self.beginRemoveRows(parentIdx, row, row)
+            del parent.parent.childs[row]
+            self.endRemoveRows()
+            parent.parent.childCount -= 1
+            return
+            
+        elif itemStartIndex == -2:
             parent.currentCount = parent.absolutCount
             # Remove items which are left over at the end of child list
             self.__cleanupParentList(parent, parentIdx)
@@ -357,11 +366,11 @@
             
         elif itemStartIndex == -1:
             parent.methodCount = len(vlist)
-            parent.currentCount = parent.absolutCount
-            idx = parent.childCount
+            idx = parent.childCount = parent.currentCount + 1
+            parent.currentCount += 1 + len(vlist)
         else:
+            idx = parent.currentCount + 1
             parent.currentCount += len(vlist)
-            idx = itemStartIndex
         
         # Sort items for Python versions where dict doesn't retain order
         vlist.sort(key=lambda x: x[0])
@@ -481,6 +490,7 @@
         
         # Little quirk: Refresh all visible items to clear the changed marker
         if parentIdx == QModelIndex():
+            self.rootNode.currentCount = -1
             idxStart = self.index(0, 0, QModelIndex())
             idxEnd = self.index(0, 2, QModelIndex())
             self.dataChanged.emit(idxStart, idxEnd)

eric ide

mercurial