diff --git a/src/cli/grampscli.py b/src/cli/grampscli.py index 35774698d..86a363322 100644 --- a/src/cli/grampscli.py +++ b/src/cli/grampscli.py @@ -145,15 +145,14 @@ class CLIDbLoader(object): mode = 'w' dbclass = DbBsddb - - self.dbstate.change_database(dbclass()) - self.dbstate.db.disable_signals() + dbclass.disable_signals() self._begin_progress() try: - self.dbstate.db.load(filename, self._pulse_progress, mode) - self.dbstate.db.set_save_path(filename) + dbclass.load(filename, self._pulse_progress, mode) + dbclass.set_save_path(filename) + self.dbstate.change_database(dbclass()) except gen.db.exceptions.DbUpgradeRequiredError, msg: self.dbstate.no_database() self._errordialog( _("Cannot open database"), str(msg)) diff --git a/src/gen/dbstate.py b/src/gen/dbstate.py index a8d04b8bf..156fcb420 100644 --- a/src/gen/dbstate.py +++ b/src/gen/dbstate.py @@ -55,6 +55,7 @@ class DbState(Callback): Closes the existing db, and opens a new one. Retained for backward compatibility. """ + self.emit('no-database', ()) self.db.close() self.change_database_noclose(database) @@ -74,6 +75,7 @@ class DbState(Callback): config.get('preferences.rprefix'), config.get('preferences.nprefix') ) self.open = True + self.signal_change() def signal_change(self): """ @@ -85,6 +87,7 @@ class DbState(Callback): """ Closes the database without a new database """ + self.emit('no-database', ()) self.db.close() self.db = DbBsddbRead() self.db.db_is_open = False diff --git a/src/gui/dbloader.py b/src/gui/dbloader.py index e4900cd59..954b75a75 100644 --- a/src/gui/dbloader.py +++ b/src/gui/dbloader.py @@ -291,23 +291,28 @@ class DbLoader(CLIDbLoader): else: mode = 'w' - self.dbstate.change_database(gen.db.DbBsddb()) - self.dbstate.db.disable_signals() + db = gen.db.DbBsddb() + db.disable_signals() + self.dbstate.no_database() self._begin_progress() try: try: - self.dbstate.db.load(filename, self._pulse_progress, + db.load(filename, self._pulse_progress, mode, upgrade=False) + self.dbstate.change_database(db) except gen.db.exceptions.DbUpgradeRequiredError, msg: if QuestionDialog2(_("Need to upgrade database!"), str(msg), _("Upgrade now"), _("Cancel")).run(): - self.dbstate.db.load(filename, self._pulse_progress, + db = gen.db.DbBsddb() + db.disable_signals() + db.load(filename, self._pulse_progress, mode, upgrade=True) - self.dbstate.db.set_save_path(filename) + db.set_save_path(filename) + self.dbstate.change_database(db) else: self.dbstate.no_database() except gen.db.exceptions.BsddbDowngradeError, msg: diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index 9f5ea3634..2becee8ec 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -122,6 +122,11 @@ class ListView(NavigationView): dbstate.connect('database-changed', self.change_db) self.connect_signals() + def no_database(self): + self.list.set_model(None) + self.model = None + self.build_tree() + def type_list(self): """ set the listtype, this governs eg keybinding diff --git a/src/plugins/lib/libpersonview.py b/src/plugins/lib/libpersonview.py index 67808f5b1..f64f7ad99 100644 --- a/src/plugins/lib/libpersonview.py +++ b/src/plugins/lib/libpersonview.py @@ -128,7 +128,8 @@ class BasePersonView(ListView): 'person-delete' : self.row_delete, 'person-rebuild' : self.object_build, 'person-groupname-rebuild' : self.object_build, - 'tag-update' : self.tag_updated + 'tag-update' : self.tag_updated, + 'no-database': self.no_database, } ListView.__init__(