mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix 'Copy to selected' on dynamic RNA properties failing in some cases.
Related to #119999 and #122059. In case the _source_ PropertyRNA was unset (i.e. its underlying IDProperty storage did not exist), the copy operation would silently fail. In fact, the existing code handling IDProperties separately in `RNA_property_copy` was pretty bad, since it would also bypass all the RNA 'setting value' code (like custom setters, update handling). Turns out, liboverride RNA apply code can already handle all of these cases, so simply pass the raw 'unresolved' RNA property to it, and remove all this special handling code from `RNA_property_copy`, solves all the issues.
This commit is contained in:
parent
6807f35a8f
commit
267df240b2
1 changed files with 1 additions and 26 deletions
|
|
@ -218,38 +218,13 @@ bool RNA_property_copy(
|
|||
return false;
|
||||
}
|
||||
|
||||
PropertyRNA *prop_dst = prop;
|
||||
PropertyRNA *prop_src = prop;
|
||||
|
||||
/* Ensure we get real property data,
|
||||
* be it an actual RNA property, or an #IDProperty in disguise. */
|
||||
prop_dst = rna_ensure_property_realdata(&prop_dst, ptr);
|
||||
prop_src = rna_ensure_property_realdata(&prop_src, fromptr);
|
||||
|
||||
/* IDprops: destination may not exist, if source does and is set, try to create it. */
|
||||
/* NOTE: this is sort of quick hack/bandage to fix the issue,
|
||||
* we need to rethink how IDProps are handled in 'diff' RNA code completely, IMHO. */
|
||||
if (prop_src != NULL && prop_dst == NULL && RNA_property_is_set(fromptr, prop)) {
|
||||
BLI_assert(prop_src->magic != RNA_MAGIC);
|
||||
IDProperty *idp_dst = RNA_struct_idprops(ptr, true);
|
||||
IDProperty *prop_idp_dst = IDP_CopyProperty((IDProperty *)prop_src);
|
||||
IDP_AddToGroup(idp_dst, prop_idp_dst);
|
||||
rna_idproperty_touch(prop_idp_dst);
|
||||
/* Nothing else to do here... */
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ELEM(NULL, prop_dst, prop_src)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IDOverrideLibraryPropertyOperation opop = {
|
||||
.operation = LIBOVERRIDE_OP_REPLACE,
|
||||
.subitem_reference_index = index,
|
||||
.subitem_local_index = index,
|
||||
};
|
||||
return rna_property_override_operation_apply(
|
||||
bmain, ptr, fromptr, NULL, prop_dst, prop_src, NULL, NULL, NULL, NULL, &opop);
|
||||
bmain, ptr, fromptr, NULL, prop, prop, NULL, NULL, NULL, NULL, &opop);
|
||||
}
|
||||
|
||||
static int rna_property_override_diff(Main *bmain,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue