forked from bartvdbraak/blender
Fix T61497: Old keymap causes error on startup
When a keymap has an error loading, don't make it active since it will be partially loaded and not usable.
This commit is contained in:
parent
a9da750aee
commit
6c2a0049e4
@ -587,15 +587,12 @@ def keyconfig_init():
|
||||
|
||||
def keyconfig_set(filepath, report=None):
|
||||
from os.path import basename, splitext
|
||||
from itertools import chain
|
||||
|
||||
if _bpy.app.debug_python:
|
||||
print("loading preset:", filepath)
|
||||
|
||||
keyconfigs = _bpy.context.window_manager.keyconfigs
|
||||
|
||||
keyconfigs_old = keyconfigs[:]
|
||||
|
||||
try:
|
||||
error_msg = ""
|
||||
execfile(filepath)
|
||||
@ -603,17 +600,18 @@ 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)
|
||||
|
||||
kc_new = next(chain(iter(kc for kc in keyconfigs
|
||||
if kc not in keyconfigs_old), (None,)))
|
||||
if kc_new is not None:
|
||||
keyconfigs.remove(kc_new)
|
||||
return False
|
||||
|
||||
# Get name, exception for default keymap to keep backwards compatibility.
|
||||
name = splitext(basename(filepath))[0]
|
||||
kc_new = keyconfigs.get(name)
|
||||
if kc_new is None:
|
||||
if report is not None:
|
||||
report({'ERROR'}, "Failed to load keymap %r" % filepath)
|
||||
|
Loading…
Reference in New Issue
Block a user