ignore broken reset hooks in database check

ideally the original code should be correctly cleaning up the hooks,
but if it does not, then we don't want to repeatedly present the user
with confusing errors when they try to check their database is ok.
This commit is contained in:
Damien Elmes 2018-12-15 13:14:33 +10:00
parent d6d5677fa8
commit a6c34fd79f
2 changed files with 21 additions and 3 deletions

View file

@ -25,13 +25,21 @@ def runHook(hook, *args):
hook = _hooks.get(hook, None) hook = _hooks.get(hook, None)
if hook: if hook:
for func in hook: for func in hook:
try:
func(*args) func(*args)
except:
hook.remove(func)
raise
def runFilter(hook, arg, *args): def runFilter(hook, arg, *args):
hook = _hooks.get(hook, None) hook = _hooks.get(hook, None)
if hook: if hook:
for func in hook: for func in hook:
try:
arg = func(arg, *args) arg = func(arg, *args)
except:
hook.remove(func)
raise
return arg return arg
def addHook(hook, func): def addHook(hook, func):

View file

@ -1054,7 +1054,17 @@ will be lost. Continue?"""))
showText(ret) showText(ret)
else: else:
tooltip(ret) tooltip(ret)
# if an error has directed the user to check the database,
# silently clean up any broken reset hooks which distract from
# the underlying issue
while True:
try:
self.reset() self.reset()
break
except Exception as e:
print("swallowed exception in reset hook:", e)
continue
return ret return ret
def onCheckMediaDB(self): def onCheckMediaDB(self):