From 8a71ef735f3f430b683fa8406fd5a597ffa42804 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 18 Jun 2010 13:04:09 +0100 Subject: [PATCH] Fix for bug #5865 --- src/calibre/gui2/device.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 07b5063e6c..36faee6dcb 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -602,7 +602,6 @@ class Emailer(Thread): # {{{ class DeviceMixin(object): # {{{ def __init__(self): - self.db_book_uuid_cache = set() self.device_error_dialog = error_dialog(self, _('Error'), _('Error communicating with device'), ' ') self.device_error_dialog.setModal(Qt.NonModal) @@ -1350,8 +1349,13 @@ class DeviceMixin(object): # {{{ return loc def set_books_in_library(self, booklists, reset=False): - if reset: - # First build a cache of the library, so the search isn't On**2 + # Force a reset if the caches are not initialized + if reset or not hasattr(self, 'db_book_title_cache'): + # It might be possible to get here without having initialized the + # library view. In this case, simply give up + if not hasattr(self, 'library_view') or self.library_view 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