Viewer: Fix error when trying to change more than a single keyboard shortcut at once. Fixes #1858117 [ERROR: Unhandled error: Uncaught TypeError when setting custom keyboard shortcut in viewer](https://bugs.launchpad.net/calibre/+bug/1858117)

This commit is contained in:
Kovid Goyal 2020-01-02 22:13:36 +05:30
parent ecdf7f74e0
commit fc8659e07a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -84,7 +84,7 @@ def close_customize_shortcut(apply_changes):
item.dataset.userData = JSON.stringify(q)
break
get_container().dataset.changed = 'true'
commit_keyboard(create_keyboard_panel.onchange)
commit_keyboard(create_keyboard_panel.onchange, None)
def add_key_widget():
@ -184,7 +184,7 @@ def shortcuts_differ(a, b):
return False
def commit_keyboard(onchange):
def commit_keyboard(onchange, container):
sd = get_session_data()
vals = {}
for item in get_container().querySelectorAll('[data-user-data]'):
@ -192,6 +192,7 @@ def commit_keyboard(onchange):
if shortcuts_differ(q.shortcuts, shortcuts_definition()[q.name].shortcuts):
vals[q.name] = q.shortcuts
sd.set('keyboard_shortcuts', vals)
create_keyboard_panel.onchange = None
if container is not None:
create_keyboard_panel.onchange = None
if get_container().dataset.changed is 'true':
onchange()