Fix regression that caused memory leak in Tag Browser. This would show up as the memory usage of calibre increasing when switching libraries. Fixes #9246 (Memory allocation while changing library)

This commit is contained in:
Kovid Goyal 2011-03-02 12:47:36 -07:00
parent f0ef93ead5
commit 46bcddc10f
2 changed files with 9 additions and 0 deletions

View File

@ -355,6 +355,7 @@ class ChooseLibraryAction(InterfaceAction):
print
print 'before:', self.before_mem
print 'after:', memory()/1024**2
print
self.dbref = self.before_mem = None

View File

@ -572,6 +572,13 @@ class TagTreeItem(object): # {{{
else:
self.tooltip = ''
def break_cycles(self):
for x in self.children:
if hasattr(x, 'break_cycles'):
x.break_cycles()
self.parent = self.icon_state_map = self.bold_font = self.tag = \
self.icon = self.children = None
def __str__(self):
if self.type == self.ROOT:
return 'ROOT'
@ -780,6 +787,7 @@ class TagsModel(QAbstractItemModel): # {{{
self.refresh(data=data)
def break_cycles(self):
self.root_item.break_cycles()
self.db = self.root_item = None
def mimeTypes(self):