From d0df7fb3b94ea85dd783f372c3f926d250944305 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 3 Mar 2019 21:56:38 +0100 Subject: Fix (unreported) missing handling of 'never self' ID pointers in library_query and library_remap codes. Looks like something forgotten at some point, define in callback flags was there, just not used at all. Added most obvious cases now (we are probably still missing some), and proper handling for it in remapping code (when we hit such case, we 'convert' new_id to NULL and go on with it). Related (as in, exposed by) T62076, but not the actual cause of that bug. --- source/blender/blenkernel/intern/library_remap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/library_remap.c') diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index c4cd14e027e..03630297dc3 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -180,6 +180,11 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id } if (*id_p && (*id_p == old_id)) { + /* Better remap to NULL than not remapping at all, then we can handle it as a regular remap-to-NULL case... */ + if ((cb_flag & IDWALK_CB_NEVER_SELF) && (new_id == id_self)) { + new_id = NULL; + } + const bool is_reference = (cb_flag & IDWALK_CB_STATIC_OVERRIDE_REFERENCE) != 0; const bool is_indirect = (cb_flag & IDWALK_CB_INDIRECT_USAGE) != 0; const bool skip_indirect = (id_remap_data->flag & ID_REMAP_SKIP_INDIRECT_USAGE) != 0; @@ -189,7 +194,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id const bool is_obj = (GS(id->name) == ID_OB); const bool is_obj_proxy = (is_obj && (((Object *)id)->proxy || ((Object *)id)->proxy_group)); const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id)); - const bool is_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) && + const bool is_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && + (new_id == NULL) && (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0); const bool skip_reference = (id_remap_data->flag & ID_REMAP_SKIP_STATIC_OVERRIDE) != 0; const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0; -- cgit v1.2.3