diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2021-03-16 19:05:28 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2021-03-16 19:05:28 +0300 |
commit | c3b43de9ece49e4f72a35f9b6e8734657e039adf (patch) | |
tree | cf2d51e25ee2e5c493cc60b3da5017e76bfb5f45 | |
parent | f04606087f56c6f943f1170ed2d220a131fd5cc5 (diff) |
Bone Selection Sets: avoid error when running headless
When running Blender in the background (`-b` CLI option),
`window_manager.keyconfigs.addon` is `None`. This is now checked for
instead of causing an `AttributeError`.
-rw-r--r-- | bone_selection_sets.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bone_selection_sets.py b/bone_selection_sets.py index 7a382d75..391f183a 100644 --- a/bone_selection_sets.py +++ b/bone_selection_sets.py @@ -560,10 +560,12 @@ def register(): # Add shortcuts to the keymap. wm = bpy.context.window_manager - km = wm.keyconfigs.addon.keymaps.new(name='Pose') - kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True, shift=True) - kmi.properties.name = 'POSE_MT_selection_sets_select' - addon_keymaps.append((km, kmi)) + if wm.keyconfigs.addon is not None: + # wm.keyconfigs.addon is None when Blender is running in the background. + km = wm.keyconfigs.addon.keymaps.new(name='Pose') + kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True, shift=True) + kmi.properties.name = 'POSE_MT_selection_sets_select' + addon_keymaps.append((km, kmi)) # Add entries to menus. bpy.types.VIEW3D_MT_select_pose.append(menu_func_select_selection_set) |