diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-12-18 14:45:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-12-18 14:49:48 +0300 |
commit | c1eec5582aa9c1e5f8aa7b5e7a2893ed2560cb0d (patch) | |
tree | c8bbf2660576862b8420fa06c6cc15ba96424d18 /source | |
parent | 8627d65951b56a619419712c963f70b58d7106cb (diff) |
Fix/workaround T42944: Crash adding a shortcut in properties space
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 413f87864f6..86414d98951 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -107,6 +107,9 @@ #define UI_MAX_PASSWORD_STR 128 +/* This hack is needed because we don't have a good way to re-reference keymap items once added: T42944 */ +#define USE_KEYMAP_ADD_HACK + /* proto */ static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to); static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to); @@ -5795,6 +5798,10 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) return block; } +#ifdef USE_KEYMAP_ADD_HACK +static int g_kmi_id_hack; +#endif + static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) { wmWindowManager *wm = CTX_wm_manager(C); @@ -5835,7 +5842,10 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); UI_block_bounds_set_popup(block, 6, -50, 26); - + +#ifdef USE_KEYMAP_ADD_HACK + g_kmi_id_hack = kmi_id; +#endif return block; } @@ -5844,9 +5854,20 @@ static void menu_add_shortcut_cancel(struct bContext *C, void *arg1) uiBut *but = (uiBut *)arg1; wmKeyMap *km; wmKeyMapItem *kmi; - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); - +#ifndef USE_KEYMAP_ADD_HACK + IDProperty *prop; +#endif + int kmi_id; + +#ifdef USE_KEYMAP_ADD_HACK + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi_id = g_kmi_id_hack; + UNUSED_VARS(but); +#else + prop = (but->opptr) ? but->opptr->data : NULL; + kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); +#endif + kmi = WM_keymap_item_find_id(km, kmi_id); WM_keymap_remove_item(km, kmi); } |