[Bf-blender-cvs] [9fb59244466] blender2.8: Fix a very nasty and sneaky bug in lib remap / static override code.

Bastien Montagne noreply at git.blender.org
Mon Jun 18 20:21:04 CEST 2018


Commit: 9fb59244466aa07c9addaf17bdb65192682bde87
Author: Bastien Montagne
Date:   Mon Jun 18 20:17:44 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9fb59244466aa07c9addaf17bdb65192682bde87

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

===================================================================

M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/library_remap.c

===================================================================

diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 37b5b62b06e..f23d8720a65 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -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);
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 7b9d9136629..f34a2ff7f84 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -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)) {



More information about the Bf-blender-cvs mailing list