diff --git a/src/calibre/gui2/actions/__init__.py b/src/calibre/gui2/actions/__init__.py index 387caf3c50..444541141c 100644 --- a/src/calibre/gui2/actions/__init__.py +++ b/src/calibre/gui2/actions/__init__.py @@ -324,6 +324,16 @@ class InterfaceAction(QObject): ''' pass + def library_about_to_change(self, olddb, db): + ''' + Called whenever the current library is changed. + + :param olddb: The LibraryDatabase corresponding to the previous library. + :param db: The LibraryDatabase corresponding to the new library. + + ''' + pass + def library_changed(self, db): ''' Called whenever the current library is changed. diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 9315224a3f..34bafb85e0 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -872,6 +872,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ return else: return + for action in self.iactions.values(): + try: + action.library_about_to_change(olddb, db) + except Exception: + import traceback + traceback.print_exc() self.library_path = newloc prefs['library_path'] = self.library_path self.book_on_device(None, reset=True) @@ -893,7 +899,11 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ self.apply_virtual_library(db.new_api.pref('virtual_lib_on_startup')) self.rebuild_vl_tabs() for action in self.iactions.values(): - action.library_changed(db) + try: + action.library_changed(db) + except Exception: + import traceback + traceback.print_exc() self.library_broker.gui_library_changed(db, olddb) if self.device_connected: self.set_books_in_library(self.booklists(), reset=True)