Fix a very nasty and sneaky bug in lib remap / static override code.

Not sure why remap call for static override reference ID pointer was put
there, probably a mistake during some merge back in the days...

But this ended up with self_id of libquery data struct still being set
to previous ID pointer, which could randomly generate crap like falsly
reporting indirect data and such, leading to lost reference datablock at
writefile time...
This commit is contained in:
Bastien Montagne 2018-06-18 20:17:44 +02:00
parent 176bbe3466
commit 9fb5924446
2 changed files with 9 additions and 6 deletions

View File

@ -352,10 +352,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
#define CALLBACK_INVOKE(check_id_super, cb_flag) \
FOREACH_CALLBACK_INVOKE(&data, check_id_super, cb_flag)
if (id->override_static != NULL) {
CALLBACK_INVOKE_ID(id->override_static->reference, IDWALK_CB_USER | IDWALK_CB_STATIC_OVERRIDE_REFERENCE);
}
for (; id != NULL; id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL) {
data.self_id = id;
data.cb_flag = ID_IS_LINKED(id) ? IDWALK_CB_INDIRECT_USAGE : 0;
@ -372,6 +368,11 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
continue;
}
if (id->override_static != NULL) {
CALLBACK_INVOKE_ID(id->override_static->reference, IDWALK_CB_USER | IDWALK_CB_STATIC_OVERRIDE_REFERENCE);
CALLBACK_INVOKE_ID(id->override_static->storage, IDWALK_CB_USER | IDWALK_CB_STATIC_OVERRIDE_REFERENCE);
}
library_foreach_idproperty_ID_link(&data, id->properties, IDWALK_CB_USER);
AnimData *adt = BKE_animdata_from_id(id);

View File

@ -195,8 +195,10 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0;
#ifdef DEBUG_PRINT
printf("In %s: Remapping %s (%p) to %s (%p) (is_indirect: %d, skip_indirect: %d)\n",
id->name, old_id->name, old_id, new_id ? new_id->name : "<NONE>", new_id, is_indirect, skip_indirect);
printf("In %s (lib %p): Remapping %s (%p) to %s (%p) "
"(is_indirect: %d, skip_indirect: %d, is_reference: %d, skip_reference: %d)\n",
id->name, id->lib, old_id->name, old_id, new_id ? new_id->name : "<NONE>", new_id,
is_indirect, skip_indirect, is_reference, skip_reference);
#endif
if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && (cb_flag & IDWALK_CB_NEVER_NULL)) {