Prevent stale ondevice info from showing during connections by emptying the device databases on disconnect. See http://www.mobileread.com/forums/showthread.php?t=249540

This commit is contained in:
Charles Haley 2014-11-05 16:31:19 +01:00
parent 851617caed
commit 3cfada60a6

View File

@ -1070,7 +1070,7 @@ class DeviceMixin(object): # {{{
self.device_manager.device.get_gui_name()+ self.device_manager.device.get_gui_name()+
_(' detected.'), 3000) _(' detected.'), 3000)
self.library_view.set_device_connected(self.device_connected) self.library_view.set_device_connected(self.device_connected)
self.refresh_ondevice(reset_only=True) self.refresh_ondevice()
else: else:
self.device_connected = None self.device_connected = None
self.status_bar.device_disconnected() self.status_bar.device_disconnected()
@ -1079,6 +1079,10 @@ class DeviceMixin(object): # {{{
self.location_manager.update_devices() self.location_manager.update_devices()
self.bars_manager.update_bars() self.bars_manager.update_bars()
self.library_view.set_device_connected(self.device_connected) self.library_view.set_device_connected(self.device_connected)
# Empty any device view information
self.memory_view.set_database([])
self.card_a_view.set_database([])
self.card_b_view.set_database([])
self.refresh_ondevice() self.refresh_ondevice()
device_signals.device_connection_changed.emit(connected) device_signals.device_connection_changed.emit(connected)
@ -1142,15 +1146,13 @@ class DeviceMixin(object): # {{{
prints('DeviceJob: metadata_downloaded: sending metadata_available signal') prints('DeviceJob: metadata_downloaded: sending metadata_available signal')
device_signals.device_metadata_available.emit() device_signals.device_metadata_available.emit()
def refresh_ondevice(self, reset_only=False): def refresh_ondevice(self):
''' '''
Force the library view to refresh, taking into consideration new Force the library view to refresh, taking into consideration new
device books information device books information
''' '''
with self.library_view.preserve_state(): with self.library_view.preserve_state():
self.book_on_device(None, reset=True) self.book_on_device(None, reset=True)
if reset_only:
return
self.library_view.model().refresh_ondevice() self.library_view.model().refresh_ondevice()
# }}} # }}}
@ -1183,7 +1185,7 @@ class DeviceMixin(object): # {{{
self.upload_booklists(job) self.upload_booklists(job)
# We need to reset the ondevice flags in the library. Use a big hammer, # We need to reset the ondevice flags in the library. Use a big hammer,
# so we don't need to worry about whether some succeeded or not. # so we don't need to worry about whether some succeeded or not.
self.refresh_ondevice(reset_only=False) self.refresh_ondevice()
try: try:
if not self.current_view().currentIndex().isValid(): if not self.current_view().currentIndex().isValid():