From f8a3636374b76f6db31be21beaa0e40857644bc4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 23 Jun 2018 10:31:10 +0200 Subject: UI: alternate fix for empty context menu block and layout could be NULL and checking this everywhere wasn't practical. Instead of lazy initializing, add UI_popup_menu_end_or_cancel which cancels empty popup menus. --- source/blender/editors/interface/interface.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/interface/interface.c') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 895190ab885..90fb477480a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4007,6 +4007,16 @@ int UI_blocklist_min_y_get(ListBase *lb) return min; } +bool UI_block_is_empty(const uiBlock *block) +{ + for (const uiBut *but = block->buttons.first; but; but = but->next) { + if (!ELEM(but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { + return false; + } + } + return true; +} + void UI_block_direction_set(uiBlock *block, char direction) { block->direction = direction; @@ -4753,4 +4763,3 @@ void UI_exit(void) ui_resources_free(); ui_but_clipboard_free(); } - -- cgit v1.2.3