Fix/workaround T42944: Crash adding a shortcut in properties space
This commit is contained in:
parent
8627d65951
commit
c1eec5582a
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue