WM: use Python bytecode cache to run presets
Key-maps can be very large, avoid parsing on every startup.
This commit is contained in:
parent
49cd13768f
commit
5ec1d709e7
@ -514,7 +514,7 @@ def keyconfig_module_from_preset(name, preset_reference_filename=None):
|
||||
preset_path = bpy.utils.preset_find(name, "keyconfig")
|
||||
|
||||
# module name isn't used or added to 'sys.modules'.
|
||||
mod_spec = importlib.util.spec_from_file_location("__bl_keymap__", preset_path)
|
||||
mod_spec = importlib.util.spec_from_file_location("__main__", preset_path)
|
||||
mod = importlib.util.module_from_spec(mod_spec)
|
||||
mod_spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
@ -245,9 +245,14 @@ class ExecutePreset(Operator):
|
||||
if hasattr(preset_class, "reset_cb"):
|
||||
preset_class.reset_cb(context)
|
||||
|
||||
# execute the preset using script.python_file_run
|
||||
if ext == ".py":
|
||||
bpy.ops.script.python_file_run(filepath=filepath)
|
||||
import importlib.util
|
||||
mod_spec = importlib.util.spec_from_file_location("__main__", filepath)
|
||||
try:
|
||||
mod_spec.loader.exec_module(importlib.util.module_from_spec(mod_spec))
|
||||
except Exception as ex:
|
||||
self.report({'ERROR'}, "Failed to executge the preset: " + repr(ex))
|
||||
|
||||
elif ext == ".xml":
|
||||
import rna_xml
|
||||
rna_xml.xml_file_run(context,
|
||||
|
Loading…
x
Reference in New Issue
Block a user