Fix LibOverride asserting when same RNA path changes type.
Although rare (and not recommended!), it can happen that a same exact RNA path points to a different type of data. This can come from an update of the code itself, but this is very unlikely and discouraged. However, geometry nodes and their 'modifiers' interface have made it way more easy to create such conflicting situation, since users are free to re-arrange and edit the nodes and their 'public' interface as they want... Found out while investigating some unrelated issues in some studio Gold production files (namely, `pro/shots/090_joining_whale/090_0130/090_0130-anim.blend` r2110 exhibits such issue for `OBGEO-mika-body` `modifiers["RIG-GN-mask-clothing"]["Socket_3"]`, where the RNA type changes from integer to bool).
This commit is contained in:
parent
8842982dbd
commit
6adf5adb7f
@ -2232,12 +2232,11 @@ void rna_property_override_diff_default(Main *bmain, RNAPropertyOverrideDiffCont
|
||||
}
|
||||
|
||||
if (op != nullptr) {
|
||||
if (created || op->rna_prop_type == 0) {
|
||||
op->rna_prop_type = rna_prop_type;
|
||||
}
|
||||
else {
|
||||
BLI_assert(op->rna_prop_type == rna_prop_type);
|
||||
}
|
||||
/* In theory, if the liboverride operation already existed, it should already be of the right
|
||||
* type. However, in some rare cases a same exact RNA path can end up pointing at different
|
||||
* data of a different path than when the liboverride property was created, so just always
|
||||
* ensure the type is now valid. */
|
||||
op->rna_prop_type = rna_prop_type;
|
||||
}
|
||||
|
||||
return;
|
||||
@ -2526,6 +2525,26 @@ bool rna_property_override_apply_default(Main *bmain,
|
||||
const int len_storage = rnaapply_ctx.len_storage;
|
||||
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
||||
|
||||
const PropertyType prop_src_type = RNA_property_type(prop_src);
|
||||
const PropertyType prop_dst_type = RNA_property_type(prop_dst);
|
||||
|
||||
/* It is possible that a same exact RNA path points to a different property of a different type
|
||||
* (due to changes in the program, or in some custom data...). */
|
||||
if (prop_src_type != prop_dst_type ||
|
||||
(prop_storage && prop_src_type != RNA_property_type(prop_storage)))
|
||||
{
|
||||
CLOG_WARN(&LOG_COMPARE_OVERRIDE,
|
||||
"%s.%s: Inconsistency between stored property type (%d) and linked reference one "
|
||||
"(%d), skipping liboverride apply",
|
||||
ptr_dst->owner_id->name,
|
||||
rnaapply_ctx.liboverride_property->rna_path,
|
||||
prop_src_type,
|
||||
prop_dst_type);
|
||||
/* Keep the liboverride property, update its type to the new actual one. */
|
||||
rnaapply_ctx.liboverride_property->rna_prop_type = prop_dst_type;
|
||||
return false;
|
||||
}
|
||||
|
||||
BLI_assert(len_dst == len_src && (!prop_storage || len_dst == len_storage));
|
||||
UNUSED_VARS_NDEBUG(len_src, len_storage);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user