From fdde52a80295f4ca09cb47216dc50d8e26178c29 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 7 Jun 2023 16:56:23 +0200 Subject: [PATCH 1/2] Fix #106395: Custom properties dont appear in quick favourites Issue here was that Quick Favorites use a property's **identifier** when adding [which is the bare name without brackets etc. from id properties] but when spawning the actual menu, `RNA_struct_find_property` expects the identifier to already include the brackets to know these are id properties (later on in `screen_user_menu_draw`). So to solve this, now include the needed syntax when storing the `bUserMenuItem_Prop` identfier. Seems the quickest way to append the needed characters is using `RNA_path_property_py` (not sure if there a re better ways to do this). Also note that we (need to) ignore the actual array index constructing the string [alays pass -1 here] since the index is handled separately [I tested boolean arrays and these work]. --- .../blender/editors/interface/interface_context_menu.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 9aadcaf181f..812429bdd33 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -33,6 +33,7 @@ #include "interface_intern.hh" #include "RNA_access.h" +#include "RNA_path.h" #include "RNA_prototypes.h" #ifdef WITH_PYTHON @@ -342,7 +343,9 @@ static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu * } if (but->rnaprop) { char *member_id_data_path = WM_context_path_resolve_full(C, &but->rnapoin); - const char *prop_id = RNA_property_identifier(but->rnaprop); + const char *prop_id = RNA_property_is_idprop(but->rnaprop) ? + RNA_path_property_py(&but->rnapoin, but->rnaprop, -1) : + RNA_property_identifier(but->rnaprop); bUserMenuItem *umi = (bUserMenuItem *)ED_screen_user_menu_item_find_prop( &um->items, member_id_data_path, prop_id, but->rnaindex); MEM_freeN(member_id_data_path); @@ -417,7 +420,9 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um) else if (but->rnaprop) { /* NOTE: 'member_id' may be a path. */ char *member_id_data_path = WM_context_path_resolve_full(C, &but->rnapoin); - const char *prop_id = RNA_property_identifier(but->rnaprop); + const char *prop_id = RNA_property_is_idprop(but->rnaprop) ? + RNA_path_property_py(&but->rnapoin, but->rnaprop, -1) : + RNA_property_identifier(but->rnaprop); /* NOTE: ignore 'drawstr', use property idname always. */ ED_screen_user_menu_item_add_prop(&um->items, "", member_id_data_path, prop_id, but->rnaindex); MEM_freeN(member_id_data_path); -- 2.30.2 From 3cfa9914fa2f8699773d5621a28d1b92ac8a757d Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 8 Jun 2023 10:29:40 +0200 Subject: [PATCH 2/2] Add comment --- source/blender/editors/interface/interface_context_menu.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 812429bdd33..3eb20c2698f 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -343,6 +343,7 @@ static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu * } if (but->rnaprop) { char *member_id_data_path = WM_context_path_resolve_full(C, &but->rnapoin); + /* Ignore the actual array index [pass -1] since the index is handled separately. */ const char *prop_id = RNA_property_is_idprop(but->rnaprop) ? RNA_path_property_py(&but->rnapoin, but->rnaprop, -1) : RNA_property_identifier(but->rnaprop); @@ -420,6 +421,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um) else if (but->rnaprop) { /* NOTE: 'member_id' may be a path. */ char *member_id_data_path = WM_context_path_resolve_full(C, &but->rnapoin); + /* Ignore the actual array index [pass -1] since the index is handled separately. */ const char *prop_id = RNA_property_is_idprop(but->rnaprop) ? RNA_path_property_py(&but->rnapoin, but->rnaprop, -1) : RNA_property_identifier(but->rnaprop); -- 2.30.2