Fix T61497: Old keymap causes error on startup
authorCampbell Barton <ideasman42@gmail.com>
Thu, 14 Feb 2019 00:11:53 +0000 (11:11 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 14 Feb 2019 00:11:53 +0000 (11:11 +1100)
When a keymap has an error loading, don't make it active
since it will be partially loaded and not usable.

release/scripts/modules/bpy/utils/__init__.py

index b4c8c08..ce77815 100644 (file)
@@ -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)