Fix LibOverride asserting when same RNA path changes type.
buildbot/v330-code-daily-linux-x86_64 Build done. Details
buildbot/v330-code-daily-windows-amd64 Build done. Details
buildbot/v330-code-daily-darwin-arm64 Build done. Details
buildbot/v330-code-daily-darwin-x86_64 Build done. Details
buildbot/v330-code-daily-coordinator Build done. Details

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).

NOTE: Cherry-pick of 6adf5adb7f, had to do some non-trivial changes to
get it to work in older code though.

Pull Request: #119429

Pull Request: #119687
This commit is contained in:
Bastien Montagne 2024-03-05 09:46:18 +01:00 committed by Gitea
parent 988eef5f31
commit fef97afbad
2 changed files with 30 additions and 7 deletions

View File

@ -1185,6 +1185,11 @@ static void rna_property_override_apply_ex(Main *bmain,
op->rna_path,
ptr_src->owner_id->name);
}
/* Ensure RNA type of the liboverride property matches the one of the RNA property. These types
* may become desynchronized for 'valid' reasons in very rare cases (in case the same RNA path
* changes to a different type of data!). See also start of
* #rna_property_override_apply_default for details. */
op->rna_prop_type = RNA_property_type(prop_dst);
}
}

View File

@ -2120,12 +2120,11 @@ int rna_property_override_diff_default(Main *bmain,
}
if (op != NULL) {
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 0;
@ -2419,7 +2418,26 @@ bool rna_property_override_apply_default(Main *bmain,
PointerRNA *UNUSED(ptr_item_storage),
IDOverrideLibraryPropertyOperation *opop)
{
BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage));
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,
"<unknown RNA path>",
prop_src_type,
prop_dst_type);
/* Keep the liboverride property, its type will be updated to the new actual one by caller
* code. */
return false;
}
BLI_assert(len_dst == len_src && (!prop_storage || len_dst == len_storage));
UNUSED_VARS_NDEBUG(len_src, len_storage);
const bool is_array = len_dst > 0;