Silence warnings/assert about invalid embedded IDs for older blendfiles.

there is no point in warning about files that are not supposed to be
'correct' in that regard.
This commit is contained in:
Bastien Montagne 2022-09-08 16:55:46 +02:00
parent e5a7470638
commit 06a5741f42
4 changed files with 34 additions and 14 deletions

View File

@ -234,8 +234,13 @@ void BKE_collection_compat_blend_read_data(BlendDataReader *reader, SceneCollect
void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collection, ID *owner_id)
{
/* Special case for this pointer, do not rely on regular `lib_link` process here. Avoids needs
* for do_versioning, and ensures coherence of data in any case. */
BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == NULL);
* for do_versioning, and ensures coherence of data in any case.
*
* NOTE: Old versions are very often 'broken' here, just fix it silently in these cases.
*/
if (BLO_read_fileversion_get(reader) > 300) {
BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == NULL);
}
BLI_assert(owner_id == NULL || owner_id->lib == collection->id.lib);
if (owner_id != NULL && (collection->id.flag & LIB_EMBEDDED_DATA) == 0) {
/* This is unfortunate, but currently a lot of existing files (including startup ones) have
@ -244,11 +249,13 @@ void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collect
* NOTE: Using do_version is not a solution here, since this code will be called before any
* do_version takes place. Keeping it here also ensures future (or unknown existing) similar
* bugs won't go easily unnoticed. */
CLOG_WARN(&LOG,
"Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider "
"re-saving your (startup) file",
collection->id.name,
owner_id->name);
if (BLO_read_fileversion_get(reader) > 300) {
CLOG_WARN(&LOG,
"Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider "
"re-saving your (startup) file",
collection->id.name,
owner_id->name);
}
collection->id.flag |= LIB_EMBEDDED_DATA;
}
collection->owner_id = owner_id;

View File

@ -652,8 +652,13 @@ static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree)
{
/* Special case for this pointer, do not rely on regular `lib_link` process here. Avoids needs
* for do_versioning, and ensures coherence of data in any case. */
BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr);
* for do_versioning, and ensures coherence of data in any case.
*
* NOTE: Old versions are very often 'broken' here, just fix it silently in these cases.
*/
if (BLO_read_fileversion_get(reader) > 300) {
BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr);
}
BLI_assert(owner_id == NULL || owner_id->lib == ntree->id.lib);
if (owner_id != nullptr && (ntree->id.flag & LIB_EMBEDDED_DATA) == 0) {
/* This is unfortunate, but currently a lot of existing files (including startup ones) have
@ -662,11 +667,13 @@ void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree)
* NOTE: Using do_version is not a solution here, since this code will be called before any
* do_version takes place. Keeping it here also ensures future (or unknown existing) similar
* bugs won't go easily unnoticed. */
CLOG_WARN(&LOG,
"Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider "
"re-saving your (startup) file",
ntree->id.name,
owner_id->name);
if (BLO_read_fileversion_get(reader) > 300) {
CLOG_WARN(&LOG,
"Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider "
"re-saving your (startup) file",
ntree->id.name,
owner_id->name);
}
ntree->id.flag |= LIB_EMBEDDED_DATA;
}
ntree->owner_id = owner_id;

View File

@ -237,6 +237,7 @@ void BLO_read_pointer_array(BlendDataReader *reader, void **ptr_p);
/* Misc. */
int BLO_read_fileversion_get(BlendDataReader *reader);
bool BLO_read_requires_endian_switch(BlendDataReader *reader);
bool BLO_read_data_is_undo(BlendDataReader *reader);
void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr);

View File

@ -4972,6 +4972,11 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader, Library *lib, ID *id)
return newlibadr(reader->fd, lib, id);
}
int BLO_read_fileversion_get(BlendDataReader *reader)
{
return reader->fd->fileversion;
}
bool BLO_read_requires_endian_switch(BlendDataReader *reader)
{
return (reader->fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;