Cleanup: change `WM_key_event_operator_id` to `WM_key_event_operator` and make it return kmi pointer directly.
All three usages of this func were only using kmi_id to find again kmi itself, pretty dumb!
This commit is contained in:
parent
2c7a70395c
commit
59e4a56d87
|
@ -6401,10 +6401,10 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
|
|||
uiLayout *layout;
|
||||
uiStyle *style = UI_style_get_dpi();
|
||||
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);
|
||||
|
||||
kmi = WM_keymap_item_find_id(km, kmi_id);
|
||||
|
||||
kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km);
|
||||
BLI_assert(kmi != NULL);
|
||||
|
||||
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
|
||||
|
||||
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
|
||||
|
@ -6508,9 +6508,10 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
|||
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);
|
||||
|
||||
kmi = WM_keymap_item_find_id(km, kmi_id);
|
||||
|
||||
kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km);
|
||||
BLI_assert(kmi != NULL);
|
||||
|
||||
WM_keymap_remove_item(km, kmi);
|
||||
|
||||
but_shortcut_name_func(C, but, 0);
|
||||
|
@ -6753,12 +6754,8 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
|||
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
|
||||
int w = uiLayoutGetWidth(layout);
|
||||
wmKeyMap *km;
|
||||
wmKeyMapItem *kmi = NULL;
|
||||
/* We want to know if this op has a shortcut, be it hotkey or not. */
|
||||
int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, false, &km);
|
||||
|
||||
if (kmi_id)
|
||||
kmi = WM_keymap_item_find_id(km, kmi_id);
|
||||
wmKeyMapItem *kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, false, &km);
|
||||
|
||||
/* We do have a shortcut, but only keyboard ones are editbale that way... */
|
||||
if (kmi) {
|
||||
|
|
|
@ -110,7 +110,7 @@ const char *WM_key_event_string(const short type, const bool compact);
|
|||
int WM_keymap_item_raw_to_string(
|
||||
const short shift, const short ctrl, const short alt, const short oskey, const short keymodifier,
|
||||
const short val, const short type, const bool compact, const int len, char *r_str);
|
||||
int WM_key_event_operator_id(
|
||||
wmKeyMapItem *WM_key_event_operator(
|
||||
const struct bContext *C, const char *opname, int opcontext,
|
||||
struct IDProperty *properties, const bool is_hotkey,
|
||||
struct wmKeyMap **r_keymap);
|
||||
|
|
|
@ -1298,17 +1298,12 @@ char *WM_key_event_operator_string(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int WM_key_event_operator_id(
|
||||
wmKeyMapItem *WM_key_event_operator(
|
||||
const bContext *C, const char *opname, int opcontext,
|
||||
IDProperty *properties, const bool is_hotkey,
|
||||
wmKeyMap **r_keymap)
|
||||
{
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, is_hotkey, true, r_keymap);
|
||||
|
||||
if (kmi)
|
||||
return kmi->id;
|
||||
else
|
||||
return 0;
|
||||
return wm_keymap_item_find(C, opname, opcontext, properties, is_hotkey, true, r_keymap);
|
||||
}
|
||||
|
||||
int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
|
||||
|
|
Loading…
Reference in New Issue