diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-02 13:41:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-02 13:41:26 +0400 |
commit | a31449edaddc1be80676c77babf079a9f137c42d (patch) | |
tree | 30bf1759a51f5def43dc000d6af7112642404770 /source/blender/windowmanager/intern/wm_keymap.c | |
parent | 2944d42c262d9d4459e356dc8b8fbad1c53c2054 (diff) |
all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 2781ec2d3df..7aa2b403897 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -190,9 +190,9 @@ wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname) return keyconf; } -void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) +int WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) { - if (keyconf) { + if (BLI_findindex(&wm->keyconfigs, keyconf) != -1) { if (strncmp(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr)) == 0) { BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr)); WM_keyconfig_update_tag(NULL, NULL); @@ -200,6 +200,11 @@ void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) BLI_remlink(&wm->keyconfigs, keyconf); WM_keyconfig_free(keyconf); + + return TRUE; + } + else { + return FALSE; } } @@ -381,7 +386,7 @@ wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, const char *idname, int type, return kmi; } -void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) +int WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) { if (BLI_findindex(&keymap->items, kmi) != -1) { if (kmi->ptr) { @@ -391,6 +396,10 @@ void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) BLI_freelinkN(&keymap->items, kmi); WM_keyconfig_update_tag(keymap, kmi); + return TRUE; + } + else { + return FALSE; } } |