several bugfixes for rerendertabtree

It was prone to infinite loops, mixing elements etc.
This commit is contained in:
mailchuck 2015-11-09 18:44:27 +01:00 committed by Peter Surda
parent 8103874f6e
commit d9401c7180

View File

@ -460,7 +460,8 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget.setSortingEnabled(False) treeWidget.setSortingEnabled(False)
widgets = {} widgets = {}
for i in range (0, treeWidget.topLevelItemCount()): i = 0
while i < treeWidget.topLevelItemCount():
widget = treeWidget.topLevelItem(i) widget = treeWidget.topLevelItem(i)
if widget is not None: if widget is not None:
toAddress = widget.address toAddress = widget.address
@ -469,28 +470,32 @@ class MyForm(settingsmixin.SMainWindow):
if not toAddress in db: if not toAddress in db:
treeWidget.takeTopLevelItem(i) treeWidget.takeTopLevelItem(i)
i -= 1 # no increment
continue continue
unread = 0 unread = 0
for j in range (0, widget.childCount()): j = 0
while j < widget.childCount():
subwidget = widget.child(j) subwidget = widget.child(j)
try: try:
subwidget.setUnreadCount(db[toAddress][subwidget.folderName]) subwidget.setUnreadCount(db[toAddress][subwidget.folderName])
unread += db[toAddress][subwidget.folderName] unread += db[toAddress][subwidget.folderName]
db[toAddress].pop(subwidget.folderName, None) db[toAddress].pop(subwidget.folderName, None)
except: except:
widget.takeChild(i) widget.takeChild(j)
j -= 1 # no increment
continue
j += 1
# add missing folders # add missing folders
if len(db[toAddress]) > 0: if len(db[toAddress]) > 0:
i = 0 j = 0
for f, c in db[toAddress].iteritems(): for f, c in db[toAddress].iteritems():
print "adding %s, %i" % (f, c) print "adding %s, %i" % (f, c)
subwidget = Ui_FolderWidget(widget, i, toAddress, f, c) subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
i += 1 j += 1
widget.setUnreadCount(unread) widget.setUnreadCount(unread)
db.pop(toAddress, None) db.pop(toAddress, None)
i += 1
i = 0 i = 0
for toAddress in db: for toAddress in db: