This commit is contained in:
Kovid Goyal 2011-01-25 12:50:57 -07:00
parent 05be08a9ee
commit 80bb000575
3 changed files with 11 additions and 4 deletions

View File

@ -390,7 +390,7 @@ class ChooseLibraryAction(InterfaceAction):
#self.dbref = weakref.ref(self.gui.library_view.model().db)
#self.before_mem = memory()/1024**2
self.gui.library_moved(loc)
#QTimer.singleShot(1000, self.debug_leak)
#QTimer.singleShot(5000, self.debug_leak)
def debug_leak(self):
import gc
@ -398,7 +398,7 @@ class ChooseLibraryAction(InterfaceAction):
ref = self.dbref
for i in xrange(3): gc.collect()
if ref() is not None:
print 11111, ref()
print 'DB object alive:', ref()
for r in gc.get_referrers(ref())[:10]:
print r
print

View File

@ -727,7 +727,11 @@ class TagsModel(QAbstractItemModel): # {{{
for user_cat in sorted(self.db.prefs.get('user_categories', {}).keys(),
key=sort_key):
cat_name = '@' + user_cat # add the '@' to avoid name collision
tb_cats.add_user_category(label=cat_name, name=user_cat)
try:
tb_cats.add_user_category(label=cat_name, name=user_cat)
except ValueError:
import traceback
traceback.print_exc()
if len(saved_searches().names()):
tb_cats.add_search_category(label='search', name=_('Searches'))

View File

@ -42,7 +42,8 @@ class MetadataBackup(Thread): # {{{
def stop(self):
self.keep_running = False
self.flush()
def break_cycles(self):
# Break cycles so that this object doesn't hold references to db
self.do_write = self.get_metadata_for_dump = self.clear_dirtied = \
self.set_dirtied = self.db = None
@ -111,6 +112,8 @@ class MetadataBackup(Thread): # {{{
continue
self.in_limbo = None
self.flush()
self.break_cycles()
def flush(self):
'Used during shutdown to ensure that a dirtied book is not missed'