[Bf-blender-cvs] [07b8b90] id-remap: Fix assert when deleting obdata.
Bastien Montagne
noreply at git.blender.org
Thu Jan 7 16:15:11 CET 2016
Commit: 07b8b90f3913d1e24ec6429b93f8a4ea437ac0e1
Author: Bastien Montagne
Date: Thu Jan 7 16:11:14 2016 +0100
Branches: id-remap
https://developer.blender.org/rB07b8b90f3913d1e24ec6429b93f8a4ea437ac0e1
Fix assert when deleting obdata.
Issue here is again with NEVER_NULL usages: obdata (& co) would be dereferenced twice.
I'm not totally happy with this solution, ideally remap should never leave Main
in invalid state, but for now it will do...
===================================================================
M source/blender/blenkernel/BKE_library.h
M source/blender/blenkernel/intern/library.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 4ab2cb6..6bf7522 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -82,6 +82,9 @@ enum {
/* This tells the callback func to flag with LIB_DOIT all IDs using target one with a 'never NULL' pointer
* (like e.g. Object->data). */
ID_REMAP_FLAG_NEVER_NULL_USAGE = 1 << 2,
+ /* This tells the callback func to force setting IDs using target one with a 'never NULL' pointer to NULL.
+ * WARNING! Use with extreme care, this will leave database in broken state! */
+ ID_REMAP_FORCE_NEVER_NULL_USAGE = 1 << 3,
};
/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately, but makes things simpler for now. */
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index cbb0057..0d75285 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1084,7 +1084,8 @@ static bool foreach_libblock_remap_callback(void *user_data, ID **id_p, int cb_f
/* Note that indirect data from same file as processed ID is **not** considered indirect! */
const bool is_indirect = ((id->lib != NULL) && (id->lib != old_id->lib));
const bool skip_indirect = (id_remap_data->flag & ID_REMAP_SKIP_INDIRECT_USAGE) != 0;
- const bool is_never_null = ((cb_flag & IDWALK_NEVER_NULL) && (new_id == NULL));
+ const bool is_never_null = ((cb_flag & IDWALK_NEVER_NULL) && (new_id == NULL) &&
+ (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0);
const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0;
if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && (cb_flag & IDWALK_NEVER_NULL)) {
@@ -1628,7 +1629,7 @@ void BKE_libblock_delete(Main *bmain, void *idv)
* links, this can lead to nasty crashing here in second, actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
- BKE_libblock_remap(bmain, id, NULL, ID_REMAP_FLAG_NEVER_NULL_USAGE);
+ BKE_libblock_remap(bmain, id, NULL, ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE);
}
}
}
More information about the Bf-blender-cvs
mailing list