From d808557d15dbf09401d8ab40c59ce69c89a2d041 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Mar 2017 13:26:34 +1100 Subject: Fix memory leak re-registering operators Re-registering an operator used by the keymap would lead memory. Reload scripts for eg leaked over ~1600 blocks. --- source/blender/windowmanager/intern/wm_keymap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index e201fa433d4..db5fc23146f 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -121,6 +121,13 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi) if (ot->srna != kmi->ptr->type) { /* matches wm_keymap_item_properties_set but doesnt alloc new ptr */ WM_operator_properties_create_ptr(kmi->ptr, ot); + /* 'kmi->ptr->data' NULL'd above, keep using existing properties. + * Note: the operators property types may have changed, + * we will need a more comprehensive sanitize function to support this properly. + */ + if (kmi->properties) { + kmi->ptr->data = kmi->properties; + } WM_operator_properties_sanitize(kmi->ptr, 1); } } -- cgit v1.2.3