From 071f46766020eea37fc2983179294347bddcc91d Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 26 Sep 2023 16:20:54 +0200 Subject: [PATCH] Fix #90732: crash on alt+LMB to change custom properties in some cases This crashed when alt-editing a custom property that existed e.g. on one bone but not on another. To check validity there are two mechanisms: - remove non-valid in UI_context_copy_to_selected_list() - check in UI_context_copy_to_selected_check() This PR takes the first route [similar to filtering out different sequences that dont share common properties], custom properties on real IDs (such as objects or scenes) were not affected [since they kind of go the second route and provide a path for UI_context_copy_to_selected_check() which then gets validated there]. Found the first route more readable though. --- .../blender/editors/interface/interface_ops.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 78fbcbb830e..ef9f584a00f 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -1346,6 +1346,7 @@ bool UI_context_copy_to_selected_list(bContext *C, return false; } + /* Account for properties only being available for some sequence types. */ if (ensure_list_items_contain_prop) { const char *prop_id = RNA_property_identifier(prop); LISTBASE_FOREACH_MUTABLE (CollectionPointerLink *, link, r_lb) { @@ -1358,6 +1359,19 @@ bool UI_context_copy_to_selected_list(bContext *C, } } + /* Similarly account for custom properties only being available for some members in selection. */ + if (RNA_property_is_idprop(prop)) { + PointerRNA dummy_ptr; + PropertyRNA *dummy_prop; + const char *prop_py = RNA_path_property_py(ptr, prop, -1); + LISTBASE_FOREACH_MUTABLE (CollectionPointerLink *, link, r_lb) { + if (!RNA_path_resolve_property(&link->ptr, prop_py, &dummy_ptr, &dummy_prop)) { + BLI_remlink(r_lb, link); + MEM_freeN(link); + } + } + } + return true; } @@ -1388,6 +1402,9 @@ bool UI_context_copy_to_selected_check(PointerRNA *ptr, RNA_path_resolve_property(ptr_link, path, &lptr, &lprop); } else { + /* This assumes the property is valid on link (not necessarily the case for custom properties + * on e.g. bones though). But non-existing custom properties get filtered out in + * UI_context_copy_to_selected_list(). */ lptr = *ptr_link; lprop = prop; } -- 2.30.2