[Bf-blender-cvs] [59e4a56] master: Cleanup: change `WM_key_event_operator_id` to `WM_key_event_operator` and make it return kmi pointer directly.

Bastien Montagne noreply at git.blender.org
Thu Dec 3 12:41:28 CET 2015


Commit: 59e4a56d87a026fee008f152dff85ec62198c7a9
Author: Bastien Montagne
Date:   Thu Dec 3 12:38:13 2015 +0100
Branches: master
https://developer.blender.org/rB59e4a56d87a026fee008f152dff85ec62198c7a9

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!

===================================================================

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/windowmanager/WM_keymap.h
M	source/blender/windowmanager/intern/wm_keymap.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 996abfb..9a85f5b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -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) {
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 28a8340..079ade0 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -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);
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index fe32fd6..6c45152 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -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)




More information about the Bf-blender-cvs mailing list