diff -r 9bf6903cae97 -r 999f07b00a49 eric6/Debugger/VariablesViewer.py --- a/eric6/Debugger/VariablesViewer.py Sat Dec 26 11:39:35 2020 +0100 +++ b/eric6/Debugger/VariablesViewer.py Sat Dec 26 22:49:27 2020 +0100 @@ -79,6 +79,7 @@ self.currentCount = -1 # -1 indicates to (re)load children # Indicator that there are children self.hasChildren = False + self.populated = False # Indicator that item was at least once fully populated self.wasPopulated = False @@ -115,6 +116,9 @@ try: idx = dvar.index(" (ID:") dvar = dvar[:idx] + except AttributeError: + idx = dvar + dvar = str(dvar) except ValueError: pass @@ -239,16 +243,6 @@ @rtype int """ return self.childCount + self.methodCount - - @property - def populated(self): - """ - Public property returning a flag indicating if item is fully populated. - - @return item is fully populated - @rtype bool - """ - return self.currentCount >= (self.childCount + self.methodCount) class VariablesModel(QAbstractItemModel): @@ -375,17 +369,19 @@ elif itemStartIndex == -2: parent.wasPopulated = True parent.currentCount = parent.absolutCount + parent.populated = True # Remove items which are left over at the end of child list self.__cleanupParentList(parent, parentIdx) return elif itemStartIndex == -1: parent.methodCount = len(vlist) - idx = parent.childCount = parent.currentCount + 1 - parent.currentCount += 1 + len(vlist) + idx = max(parent.currentCount, 0) + parent.currentCount = idx + len(vlist) + parent.populated = True else: - idx = parent.currentCount + 1 - parent.currentCount += len(vlist) + idx = itemStartIndex + parent.currentCount = idx + len(vlist) # Sort items for Python versions where dict doesn't retain order vlist.sort(key=lambda x: x[0]) @@ -432,6 +428,7 @@ child.tooltip = newItem.tooltip child.currentCount = -1 + child.populated = False child.childCount = newItem.childCount # Highlight item because it has changed @@ -504,6 +501,7 @@ if child.currentCount >= 0: # Discard loaded elements and refresh if still expanded child.currentCount = -1 + child.populated = False row = parent.children.index(child) newParentIdx = self.index(row, 0, parentIdx) self.resetModifiedMarker( @@ -514,6 +512,7 @@ # Little quirk: Refresh all visible items to clear the changed marker if parentIdx == QModelIndex(): self.rootNode.currentCount = -1 + self.rootNode.populated = False idxStart = self.index(0, 0, QModelIndex()) idxEnd = self.index(0, 2, QModelIndex()) self.dataChanged.emit(idxStart, idxEnd)