[Bf-blender-cvs] [22474062b1a] master: Fix T58479: Quick Favorites Lets you add multiple of the same item
Philipp Oeser
noreply at git.blender.org
Tue Jan 8 14:50:10 CET 2019
Commit: 22474062b1afb11634a1579ab5c5ce92a5beea85
Author: Philipp Oeser
Date: Fri Dec 28 14:57:34 2018 +0100
Branches: master
https://developer.blender.org/rB22474062b1afb11634a1579ab5c5ce92a5beea85
Fix T58479: Quick Favorites Lets you add multiple of the same item
Reviewers: brecht
Maniphest Tasks: T58479
Differential Revision: https://developer.blender.org/D4135
===================================================================
M source/blender/editors/interface/interface_context_menu.c
===================================================================
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index fc7d3293333..5ac45580b18 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -691,13 +691,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
uiBlock *block = uiLayoutGetBlock(layout);
const int w = uiLayoutGetWidth(layout);
uiBut *but2;
-
- but2 = uiDefIconTextBut(
- block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL,
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"),
- 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0,
- "Add to a user defined context menu (stored in the user preferences)");
- UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL);
+ bool item_found = false;
uint um_array_len;
bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len);
@@ -709,14 +703,24 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
bUserMenuItem *umi = ui_but_user_menu_find(C, but, um);
if (umi != NULL) {
but2 = uiDefIconTextBut(
- block, UI_BTYPE_BUT, 0, ICON_BLANK1,
+ block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Quick Favorites"),
0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
UI_but_func_set(but2, popup_user_menu_remove_func, um, umi);
+ item_found = true;
}
}
MEM_freeN(um_array);
+ if (!item_found) {
+ but2 = uiDefIconTextBut(
+ block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL,
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"),
+ 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ "Add to a user defined context menu (stored in the user preferences)");
+ UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL);
+ }
+
uiItemS(layout);
}
More information about the Bf-blender-cvs
mailing list