From 7d5da9f48d59254db290c6bf87a4111a0d633fbc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Sep 2010 19:34:40 -0600 Subject: [PATCH 1/2] GUI deveice detection: Handle case when user yanks connected device before device connection handler is called. Fixes #6864 (Unhandled exception, probably when trying to connect to iTunes/iPad) --- src/calibre/gui2/device.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index b20cd7594f..ae3141db56 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -707,6 +707,10 @@ class DeviceMixin(object): # {{{ ''' Called when a device is connected to the computer. ''' + # This can happen as this function is called in a queued connection and + # the user could have yanked the device in the meantime + if connected and not self.device_manager.is_device_connected: + connected = False self.set_device_menu_items_state(connected) if connected: self.device_manager.get_device_information(\ From 25bacf9a97f34a360e150487b65cc940bc01988f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Sep 2010 19:59:31 -0600 Subject: [PATCH 2/2] Initialize interface actions in the order they are defined to prevent interaction dependencies from creating a problem --- src/calibre/gui2/ui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index f40eed1fcd..f8d50d1cd2 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -38,6 +38,7 @@ from calibre.gui2.init import LibraryViewMixin, LayoutMixin from calibre.gui2.search_box import SearchBoxMixin, SavedSearchBoxMixin from calibre.gui2.search_restriction_mixin import SearchRestrictionMixin from calibre.gui2.tag_view import TagBrowserMixin +from calibre.utils.ordered_dict import OrderedDict class Listener(Thread): # {{{ @@ -97,7 +98,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{ MainWindow.__init__(self, opts, parent) self.opts = opts self.device_connected = None - acmap = {} + acmap = OrderedDict() for action in interface_actions(): mod, cls = action.actual_plugin.split(':') ac = getattr(__import__(mod, fromlist=['1'], level=0), cls)(self,