Fix crash loading Blender when the key-configuration fails to load
An error in the key-map could cause the default keymap to be removed leaving Blender without a default keymap. Prevent the crash, even though Blender wont be usable in this state.
This commit is contained in:
@@ -694,6 +694,10 @@ def keyconfig_set(filepath, *, report=None):
|
||||
print("loading preset:", filepath)
|
||||
|
||||
keyconfigs = _bpy.context.window_manager.keyconfigs
|
||||
name = splitext(basename(filepath))[0]
|
||||
|
||||
# Store the old key-configuration case of error, to know if it should be removed or not on failure.
|
||||
kc_old = keyconfigs.get(name)
|
||||
|
||||
try:
|
||||
error_msg = ""
|
||||
@@ -702,14 +706,13 @@ def keyconfig_set(filepath, *, report=None):
|
||||
import traceback
|
||||
error_msg = traceback.format_exc()
|
||||
|
||||
name = splitext(basename(filepath))[0]
|
||||
kc_new = keyconfigs.get(name)
|
||||
|
||||
if error_msg:
|
||||
if report is not None:
|
||||
report({'ERROR'}, error_msg)
|
||||
print(error_msg)
|
||||
if kc_new is not None:
|
||||
if (kc_new is not None) and (kc_new != kc_old):
|
||||
keyconfigs.remove(kc_new)
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user