On restart after crash, offer to run Check & Repair
This commit is contained in:
parent
3f28b5fcb5
commit
b765d7eae0
@ -148,6 +148,7 @@ register('behavior.min-generation-years', 13)
|
|||||||
register('behavior.owner-warn', False)
|
register('behavior.owner-warn', False)
|
||||||
register('behavior.pop-plugin-status', False)
|
register('behavior.pop-plugin-status', False)
|
||||||
register('behavior.recent-export-type', 3)
|
register('behavior.recent-export-type', 3)
|
||||||
|
register('behavior.runcheck', False)
|
||||||
register('behavior.spellcheck', False)
|
register('behavior.spellcheck', False)
|
||||||
register('behavior.startup', 0)
|
register('behavior.startup', 0)
|
||||||
register('behavior.surname-guessing', 0)
|
register('behavior.surname-guessing', 0)
|
||||||
|
@ -54,6 +54,8 @@ from .gen.const import APP_GRAMPS, USER_DIRLIST, HOME_DIR, ORIG_HOME_DIR
|
|||||||
from .gen.constfunc import mac
|
from .gen.constfunc import mac
|
||||||
from .version import VERSION_TUPLE
|
from .version import VERSION_TUPLE
|
||||||
from .gen.constfunc import win, get_env_var
|
from .gen.constfunc import win, get_env_var
|
||||||
|
from .gen.config import config
|
||||||
|
from .gen.errors import HandleError
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -135,19 +137,24 @@ l = logging.getLogger()
|
|||||||
l.setLevel(logging.WARNING)
|
l.setLevel(logging.WARNING)
|
||||||
l.addHandler(stderrh)
|
l.addHandler(stderrh)
|
||||||
|
|
||||||
# put a hook on to catch any completely unhandled exceptions.
|
|
||||||
def exc_hook(type, value, tb):
|
def exc_hook(err_type, value, t_b):
|
||||||
if type == KeyboardInterrupt:
|
''' put a hook on to catch any completely unhandled exceptions. '''
|
||||||
|
if err_type == KeyboardInterrupt:
|
||||||
# Ctrl-C is not a bug.
|
# Ctrl-C is not a bug.
|
||||||
return
|
return
|
||||||
if type == IOError:
|
if err_type == IOError:
|
||||||
# strange Windows logging error on close
|
# strange Windows logging error on close
|
||||||
return
|
return
|
||||||
|
if err_type == HandleError and 'not found' in value.value:
|
||||||
|
# tell Gramps to run check & repair on next start
|
||||||
|
config.set('behavior.runcheck', True)
|
||||||
|
config.save()
|
||||||
# Use this to show variables in each frame:
|
# Use this to show variables in each frame:
|
||||||
#from gramps.gen.utils.debug import format_exception
|
#from gramps.gen.utils.debug import format_exception
|
||||||
import traceback
|
import traceback
|
||||||
LOG.error("Unhandled exception\n" +
|
LOG.error("Unhandled exception\n" +
|
||||||
"".join(traceback.format_exception(type, value, tb)))
|
"".join(traceback.format_exception(err_type, value, t_b)))
|
||||||
|
|
||||||
sys.excepthook = exc_hook
|
sys.excepthook = exc_hook
|
||||||
|
|
||||||
|
@ -980,6 +980,20 @@ class ViewManager(CLIManager):
|
|||||||
msg = "%s (%s) - Gramps" % (name, _('Read Only'))
|
msg = "%s (%s) - Gramps" % (name, _('Read Only'))
|
||||||
self.uistate.window.set_title(msg)
|
self.uistate.window.set_title(msg)
|
||||||
|
|
||||||
|
if(bool(config.get('behavior.runcheck')) and QuestionDialog2(
|
||||||
|
_("Gramps had a problem the last time it was run."),
|
||||||
|
_("Would you like to run the Check and Repair tool?"),
|
||||||
|
_("Yes"), _("No"), parent=self.uistate.window).run()):
|
||||||
|
pdata = self._pmgr.get_plugin('check')
|
||||||
|
mod = self._pmgr.load_plugin(pdata)
|
||||||
|
tool.gui_tool(dbstate=self.dbstate, user=self.user,
|
||||||
|
tool_class=getattr(mod, pdata.toolclass),
|
||||||
|
options_class=getattr(mod, pdata.optionclass),
|
||||||
|
translated_name=pdata.name,
|
||||||
|
name=pdata.id,
|
||||||
|
category=pdata.category,
|
||||||
|
callback=self.dbstate.db.request_rebuild)
|
||||||
|
config.set('behavior.runcheck', False)
|
||||||
self.__change_page(self.notebook.get_current_page())
|
self.__change_page(self.notebook.get_current_page())
|
||||||
self.uimanager.set_actions_visible(self.actiongroup, rw)
|
self.uimanager.set_actions_visible(self.actiongroup, rw)
|
||||||
self.uimanager.set_actions_visible(self.readonlygroup, True)
|
self.uimanager.set_actions_visible(self.readonlygroup, True)
|
||||||
|
Loading…
Reference in New Issue
Block a user