BKE_libblock_relink_ex: pass all remapping flags instead of a single boolean.

There is no reasons to limit access to remapping flags here, we may want
to use other options than only the ID_REMAP_SKIP_NEVER_NULL_USAGE one...
This commit is contained in:
Bastien Montagne 2019-08-29 16:34:17 +02:00
parent f4307d4bd9
commit b9c400cee2
4 changed files with 11 additions and 8 deletions

View File

@ -85,7 +85,7 @@ void BKE_libblock_relink_ex(struct Main *bmain,
void *idv,
void *old_idv,
void *new_idv,
const bool us_min_never_null) ATTR_NONNULL(1, 2);
const short remap_flags) ATTR_NONNULL(1, 2);
void BKE_libblock_relink_to_newid(struct ID *id) ATTR_NONNULL();

View File

@ -851,8 +851,8 @@ void BKE_id_swap(Main *bmain, ID *id_a, ID *id_b)
id_b->properties = id_a_back.properties;
/* Swap will have broken internal references to itself, restore them. */
BKE_libblock_relink_ex(bmain, id_a, id_b, id_a, false);
BKE_libblock_relink_ex(bmain, id_b, id_a, id_b, false);
BKE_libblock_relink_ex(bmain, id_a, id_b, id_a, ID_REMAP_SKIP_NEVER_NULL_USAGE);
BKE_libblock_relink_ex(bmain, id_b, id_a, id_b, ID_REMAP_SKIP_NEVER_NULL_USAGE);
}
/** Does *not* set ID->newid pointer. */

View File

@ -652,12 +652,11 @@ void BKE_libblock_unlink(Main *bmain,
* ... sigh
*/
void BKE_libblock_relink_ex(
Main *bmain, void *idv, void *old_idv, void *new_idv, const bool us_min_never_null)
Main *bmain, void *idv, void *old_idv, void *new_idv, const short remap_flags)
{
ID *id = idv;
ID *old_id = old_idv;
ID *new_id = new_idv;
int remap_flags = us_min_never_null ? 0 : ID_REMAP_SKIP_NEVER_NULL_USAGE;
/* No need to lock here, we are only affecting given ID, not bmain database. */
@ -945,7 +944,7 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i
#endif
if ((flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0) {
BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
BKE_libblock_relink_ex(bmain, id, NULL, NULL, 0);
}
BKE_libblock_free_datablock(id, flag);
@ -1091,7 +1090,7 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
bmain, id, NULL, ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE);
/* Since we removed ID from Main,
* we also need to unlink its own other IDs usages ourself. */
BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
BKE_libblock_relink_ex(bmain, id, NULL, NULL, 0);
/* Now we can safely mark that ID as not being in Main database anymore. */
id->tag |= LIB_TAG_NO_MAIN;
/* This is needed because we may not have remapped usages

View File

@ -268,7 +268,11 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)sce_src->nodetree, (ID **)&sce_dst->nodetree, flag);
BKE_libblock_relink_ex(bmain, sce_dst->nodetree, (void *)(&sce_src->id), &sce_dst->id, false);
BKE_libblock_relink_ex(bmain,
sce_dst->nodetree,
(void *)(&sce_src->id),
&sce_dst->id,
ID_REMAP_SKIP_NEVER_NULL_USAGE);
}
if (sce_src->rigidbody_world) {