From 17431a9f820a8f8cc034bceef2303c8f325dcc4c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 26 Sep 2006 02:07:03 +0000 Subject: [PATCH] 2006-09-25 Don Allingham * src/GrampsDb/_GrampsDBCallback.py: catch db transaction problem * src/GrampsCfg.py: reset PORT_WARN when TRANSACTION re-enabled * src/QuestionDialog.py: sync changes to config value * src/GrampsLogger/_ErrorReportAssistant.py: fix typo svn: r7330 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/GrampsCfg.py | 5 +++++ gramps2/src/GrampsDb/_GrampsDBCallback.py | 19 ++++++++++++++++++- .../src/GrampsLogger/_ErrorReportAssistant.py | 2 +- gramps2/src/QuestionDialog.py | 1 + 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5703f4875..b5a9854c5 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2006-09-25 Don Allingham + * src/GrampsDb/_GrampsDBCallback.py: catch db transaction problem + * src/GrampsCfg.py: reset PORT_WARN when TRANSACTION re-enabled + * src/QuestionDialog.py: sync changes to config value + * src/GrampsLogger/_ErrorReportAssistant.py: fix typo + 2006-09-24 Don Allingham * src/ViewManager.py: fix call to warning dialog * src/QuestionDialog.py: Don't do internal check on value diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index 6aef09351..9395d3f27 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -106,6 +106,9 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): tlabel, _('Preferences'), None) panel = gtk.Notebook() + + self.original = Config.get(Config.TRANSACTIONS) + self.window.vbox.pack_start(tlabel, padding=12) self.window.vbox.add(panel) self.window.connect('response',self.done) @@ -128,6 +131,8 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): self.show() def done(self, obj, value): + if not self.original and Config.get(Config.TRANSACTIONS): + Config.set(Config.PORT_WARN, True) self.close() def add_researcher_panel(self): diff --git a/gramps2/src/GrampsDb/_GrampsDBCallback.py b/gramps2/src/GrampsDb/_GrampsDBCallback.py index b9d3144ab..654dc358a 100644 --- a/gramps2/src/GrampsDb/_GrampsDBCallback.py +++ b/gramps2/src/GrampsDb/_GrampsDBCallback.py @@ -41,6 +41,8 @@ import types import traceback import inspect +from bsddb import db + log = sys.stderr.write #------------------------------------------------------------------------- @@ -409,7 +411,10 @@ class GrampsDBCallback(object): cb[0](fn[1],*args) elif type(fn) == types.FunctionType or \ type(fn) == types.MethodType: # call func - fn(*args) + try: + fn(*args) + except db.DBRunRecoveryError: + display_error() else: self._warn("Badly formed entry in callback map.\n") except: @@ -456,6 +461,17 @@ class GrampsDBCallback(object): GrampsDBCallback.__BLOCK_ALL_SIGNALS = False enable_all_signals = classmethod(__enable_all_signals) + + +def display_error(): + from QuestionDialog import ErrorDialog + ErrorDialog( + _('Database error'), + _('A problem as been detected in your database. ' + 'This is probably caused by opening a database that was ' + 'created with one transaction setting when the database was ' + 'created with another, or by moving a non-portable database ' + 'to a different machine.')) #------------------------------------------------------------------------- # @@ -756,3 +772,4 @@ if __name__ == "__main__": unittest.main() + diff --git a/gramps2/src/GrampsLogger/_ErrorReportAssistant.py b/gramps2/src/GrampsLogger/_ErrorReportAssistant.py index a4d4fc574..4433c9698 100644 --- a/gramps2/src/GrampsLogger/_ErrorReportAssistant.py +++ b/gramps2/src/GrampsLogger/_ErrorReportAssistant.py @@ -79,7 +79,7 @@ class ErrorReportAssistant: GrampsDisplay.url('mailto:gramps-bugs@lists.sourceforge.net?subject="bug report"&body="%s"' \ % self._final_report_text_buffer.get_text( self._final_report_text_buffer.get_start_iter(), - self._final_report_text_buffer.get_end_iter())) + self._final_report_text_buffer.get_end_iter()))) def _get_sys_information(self): if hasattr(os, "uname"): diff --git a/gramps2/src/QuestionDialog.py b/gramps2/src/QuestionDialog.py index e494fe192..0458e2e4e 100644 --- a/gramps2/src/QuestionDialog.py +++ b/gramps2/src/QuestionDialog.py @@ -275,3 +275,4 @@ class MessageHideDialog: def update_checkbox(self, obj, constant): Config.set(constant, obj.get_active()) + Config.sync()