From 552f5da3c4852cdcdfd745bf256de21a2d264f34 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 May 2019 15:30:48 +1000 Subject: Mitigate T64346: Quick Favorites items cant be removed For now don't show missing quick favorite menu items which are missing. Once menu editing is supported they could be displayed. --- source/blender/editors/screen/screen_user_menu.c | 40 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/screen/screen_user_menu.c') diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c index 0ec989db12b..08b9d010f79 100644 --- a/source/blender/editors/screen/screen_user_menu.c +++ b/source/blender/editors/screen/screen_user_menu.c @@ -194,6 +194,10 @@ void ED_screen_user_menu_item_remove(ListBase *lb, bUserMenuItem *umi) static void screen_user_menu_draw(const bContext *C, Menu *menu) { + /* Enable when we have the ability to edit menus. */ + const bool show_missing = false; + char label[512]; + uint um_array_len; bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len); bool is_empty = true; @@ -206,15 +210,32 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu) const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL; if (umi->type == USER_MENU_TYPE_OPERATOR) { bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; - IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL; - uiItemFullO( - menu->layout, umi_op->op_idname, ui_name, ICON_NONE, prop, umi_op->opcontext, 0, NULL); - is_empty = false; + wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false); + if (ot != NULL) { + IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL; + uiItemFullO_ptr(menu->layout, ot, ui_name, ICON_NONE, prop, umi_op->opcontext, 0, NULL); + is_empty = false; + } + else { + if (show_missing) { + SNPRINTF(label, "Missing: %s", umi_op->op_idname); + uiItemL(menu->layout, label, ICON_NONE); + } + } } else if (umi->type == USER_MENU_TYPE_MENU) { bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; - uiItemM(menu->layout, umi_mt->mt_idname, ui_name, ICON_NONE); - is_empty = false; + MenuType *mt = WM_menutype_find(umi_mt->mt_idname, false); + if (mt != NULL) { + uiItemM_ptr(menu->layout, mt, ui_name, ICON_NONE); + is_empty = false; + } + else { + if (show_missing) { + SNPRINTF(label, "Missing: %s", umi_mt->mt_idname); + uiItemL(menu->layout, label, ICON_NONE); + } + } } else if (umi->type == USER_MENU_TYPE_PROP) { bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; @@ -252,9 +273,10 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu) } } if (!ok) { - char label[512]; - SNPRINTF(label, "Missing: %s.%s", umi_pr->context_data_path, umi_pr->prop_id); - uiItemL(menu->layout, label, ICON_NONE); + if (show_missing) { + SNPRINTF(label, "Missing: %s.%s", umi_pr->context_data_path, umi_pr->prop_id); + uiItemL(menu->layout, label, ICON_NONE); + } } } else if (umi->type == USER_MENU_TYPE_SEP) { -- cgit v1.2.3