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:
authorJulian Eisel <julian@blender.org>2021-07-28 13:26:11 +0300
committerJulian Eisel <julian@blender.org>2021-07-28 15:44:45 +0300
commit7d0765cbdcf272f901c80fb9fd765428fc89ba02 (patch)
tree6d24c8ebfa8a3ec682879220a8f02741a0f43c50
parent8e9d06f5a0425255ce526e9c1aa7f852165749f0 (diff)
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
-rw-r--r--source/blender/editors/interface/interface_layout.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 8b9539f1d33..ea7bcf57f52 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -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);
}