blender-v3.6-release #119429

Merged
Bastien Montagne merged 3 commits from mont29/blender:blender-v3.6-release into blender-v3.6-release 2024-03-14 04:07:07 +01:00
3 changed files with 76 additions and 25 deletions

View File

@ -3938,35 +3938,62 @@ bool BKE_lib_override_library_property_operation_operands_validate(
return true;
}
void BKE_lib_override_library_validate(Main * /*bmain*/, ID *id, ReportList *reports)
void BKE_lib_override_library_validate(Main *bmain, ID *id, ReportList *reports)
{
if (id->override_library == nullptr) {
if (!ID_IS_OVERRIDE_LIBRARY(id)) {
return;
}
if (id->override_library->reference == nullptr) {
/* This is a template ID, could be linked or local, not an override. */
ID *liboverride_id = id;
IDOverrideLibrary *liboverride = id->override_library;
if (ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id)) {
liboverride = BKE_lib_override_library_get(bmain, id, nullptr, &liboverride_id);
if (!liboverride) {
/* Happens in case the given ID is a liboverride-embedded one (actual embedded ID like
* NodeTree or master collection, or shapekeys), used by a totally not-liboverride owner ID.
* Just clear the relevant ID flag.
*/
id->flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
return;
}
}
BLI_assert(liboverride);
/* NOTE: In code deleting liboverride data below, #BKE_lib_override_library_make_local is used
* instead of directly calling #BKE_lib_override_library_free, because the former also handles
* properly 'liboverride embedded' IDs, like root nodetrees, or shapekeys. */
if (liboverride->reference == nullptr) {
/* This (probably) used to be a template ID, could be linked or local, not an override. */
BKE_reportf(reports,
RPT_WARNING,
"Library override templates have been removed: removing all override data from "
"the data-block '%s'",
liboverride_id->name);
BKE_lib_override_library_make_local(nullptr, liboverride_id);
return;
}
if (id->override_library->reference == id) {
/* Very serious data corruption, cannot do much about it besides removing the reference
* (therefore making the id a local override template one only). */
if (liboverride->reference == liboverride_id) {
/* Very serious data corruption, cannot do much about it besides removing the liboverride data.
*/
BKE_reportf(reports,
RPT_ERROR,
"Data corruption: data-block '%s' is using itself as library override reference",
id->name);
id->override_library->reference = nullptr;
"Data corruption: data-block '%s' is using itself as library override reference, "
"removing all override data",
liboverride_id->name);
BKE_lib_override_library_make_local(nullptr, liboverride_id);
return;
}
if (!ID_IS_LINKED(id->override_library->reference)) {
/* Very serious data corruption, cannot do much about it besides removing the reference
* (therefore making the id a local override template one only). */
if (!ID_IS_LINKED(liboverride->reference)) {
/* Very serious data corruption, cannot do much about it besides removing the liboverride data.
*/
BKE_reportf(reports,
RPT_ERROR,
"Data corruption: data-block '%s' is using another local data-block ('%s') as "
"library override reference",
id->name,
id->override_library->reference->name);
id->override_library->reference = nullptr;
"library override reference, removing all override data",
liboverride_id->name,
liboverride->reference->name);
BKE_lib_override_library_make_local(nullptr, liboverride_id);
return;
}
}
@ -3976,7 +4003,7 @@ void BKE_lib_override_library_main_validate(Main *bmain, ReportList *reports)
ID *id;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (id->override_library != nullptr) {
if (ID_IS_OVERRIDE_LIBRARY(id)) {
BKE_lib_override_library_validate(bmain, id, reports);
}
}

View File

@ -1344,6 +1344,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

@ -2156,12 +2156,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;
@ -2449,7 +2448,27 @@ 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;