Fix menu poll function being ignored for UILayout.menu
Using `UILayout.menu()` [1] or `UILayout.menu_contents() [2], the menu would just always be added, the `poll()` check not being executed. As API user I would expect the `poll()` to deterimine visiblity of the menu. [1] https://docs.blender.org/api/current/bpy.types.UILayout.html#bpy.types.UILayout.menu [2] https://docs.blender.org/api/current/bpy.types.UILayout.html#bpy.types.UILayout.menu_contents Differential Revision: https://developer.blender.org/D12053 Reviewed by: Campbell Barton
This commit is contained in:
@@ -2911,6 +2911,12 @@ static uiBut *ui_item_menu(uiLayout *layout,
|
||||
|
||||
void uiItemM_ptr(uiLayout *layout, MenuType *mt, const char *name, int icon)
|
||||
{
|
||||
uiBlock *block = layout->root->block;
|
||||
bContext *C = block->evil_C;
|
||||
if (WM_menutype_poll(C, mt) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
name = CTX_IFACE_(mt->translation_context, mt->label);
|
||||
}
|
||||
@@ -2949,6 +2955,9 @@ void uiItemMContents(uiLayout *layout, const char *menuname)
|
||||
|
||||
uiBlock *block = layout->root->block;
|
||||
bContext *C = block->evil_C;
|
||||
if (WM_menutype_poll(C, mt) == false) {
|
||||
return;
|
||||
}
|
||||
UI_menutype_draw(C, mt, layout);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user