BlenderKit: fix T67565, unregistration could go wrong in combo with other addons since addon was un-registering whole keymap

This commit is contained in:
Vilém Duha 2019-07-24 08:40:42 +02:00
parent b3045840a1
commit 5fdd75d683
Notes: blender-bot 2023-02-14 19:11:07 +01:00
Referenced by issue #67565, Blenderkit: Breaks keymap type "Window"
Referenced by issue #67565, Blenderkit: Breaks keymap type "Window"
1 changed files with 7 additions and 8 deletions

View File

@ -1648,8 +1648,8 @@ classess = (
)
# store keymaps here to access after registration
addon_keymaps = []
# store keymap items here to access after registration
addon_keymapitems = []
def register_ui():
@ -1673,7 +1673,7 @@ def register_ui():
kmi.properties.keep_running = False
kmi.properties.do_search = False
addon_keymaps.append(km)
addon_keymapitems.append(kmi)
def unregister_ui():
@ -1685,12 +1685,11 @@ def unregister_ui():
for c in classess:
bpy.utils.unregister_class(c)
args = (None, bpy.context)
wm = bpy.context.window_manager
if not wm.keyconfigs.addon:
return
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
del addon_keymaps[:]
km = wm.keyconfigs.addon.keymaps['Window']
for kmi in addon_keymapitems:
km.keymap_items.remove(kmi)
del addon_keymapitems[:]