Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-10-31 04:44:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-31 04:44:41 +0300
commitfe3571b3620f66d352e7eac74fa0066e50ab7837 (patch)
tree167a20dc86416bb9a30a0615d287c786a921b26d /source/blender/editors/interface/interface_layout.c
parentca006deafe0b84f4d1f05c7259ad7c7efafcbfda (diff)
UI: avoid double operator type lookup
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r--source/blender/editors/interface/interface_layout.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 2dc5b91a112..b43892053ce 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2016,19 +2016,15 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo
UI_block_direction_set(layout->root->block, UI_DIR_DOWN);
}
-void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name, int icon)
+void uiItemMenuEnumO_ptr(
+ uiLayout *layout, bContext *C, wmOperatorType *ot, const char *propname,
+ const char *name, int icon)
{
- wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
MenuItemLevel *lvl;
uiBut *but;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
-
- if (!ot->srna) {
- ui_item_disabled(layout, opname);
- RNA_warning("operator missing srna '%s'", opname);
- return;
- }
+ /* Caller must check */
+ BLI_assert(ot->srna != NULL);
if (name == NULL) {
name = RNA_struct_ui_name(ot->srna);
@@ -2038,7 +2034,7 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
icon = ICON_BLANK1;
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
- BLI_strncpy(lvl->opname, opname, sizeof(lvl->opname));
+ BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
@@ -2058,6 +2054,23 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
}
}
+void uiItemMenuEnumO(
+ uiLayout *layout, bContext *C, const char *opname, const char *propname,
+ const char *name, int icon)
+{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
+
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ if (!ot->srna) {
+ ui_item_disabled(layout, opname);
+ RNA_warning("operator missing srna '%s'", opname);
+ return;
+ }
+
+ uiItemMenuEnumO_ptr(layout, C, ot, propname, name, icon);
+}
+
static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
{
MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);