From af594c16f27073bfe632e0e8d34739ad9d3b1ea5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Jun 2010 10:11:00 -0600 Subject: [PATCH] ... --- src/calibre/gui2/device.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 36faee6dcb..33191d1773 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -1355,10 +1355,12 @@ class DeviceMixin(object): # {{{ # library view. In this case, simply give up if not hasattr(self, 'library_view') or self.library_view is None: return + db = getattr(self.library_view.model(), 'db', None) + if db is None: + return # Build a cache (map) of the library, so the search isn't On**2 self.db_book_title_cache = {} self.db_book_uuid_cache = {} - db = self.library_view.model().db for id in db.data.iterallids(): mi = db.get_metadata(id, index_is_id=True) title = re.sub('(?u)\W|[_]', '', mi.title.lower())