IDManagement: Remove deprecated `BKE_libblock_relink_to_newid` usages.
Move all usages to new `BKE_libblock_relink_to_newid_new`, and rename that one to `BKE_libblock_relink_to_newid`. Fix T91413.
This commit is contained in:
parent
fb688c8d5c
commit
43bc494892
Notes:
blender-bot
2023-02-14 09:44:56 +01:00
Referenced by commit 8fbbd69946
, Fix T92629: Crash on mesh separate after rB43bc494892c3.
Referenced by issue #96330, "Make single user -> object & data" is extremely(!) slow in Blender 3.1, compared to previous versions
Referenced by issue #92670, Separate Object results in a crash
Referenced by issue #92629, Crash on mesh separate
Referenced by issue #91413, Remove deprecated `BKE_libblock_relink_to_newid` usages
|
@ -111,8 +111,7 @@ void BKE_libblock_relink_ex(struct Main *bmain,
|
|||
void *new_idv,
|
||||
const short remap_flags) ATTR_NONNULL(1, 2);
|
||||
|
||||
void BKE_libblock_relink_to_newid(struct ID *id) ATTR_NONNULL();
|
||||
void BKE_libblock_relink_to_newid_new(struct Main *bmain, struct ID *id) ATTR_NONNULL();
|
||||
void BKE_libblock_relink_to_newid(struct Main *bmain, struct ID *id) ATTR_NONNULL();
|
||||
|
||||
typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
|
||||
typedef void (*BKE_library_remap_editor_id_reference_cb)(struct ID *, struct ID *);
|
||||
|
|
|
@ -716,7 +716,7 @@ Collection *BKE_collection_duplicate(Main *bmain,
|
|||
collection_new->id.tag &= ~LIB_TAG_NEW;
|
||||
|
||||
/* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
|
||||
BKE_libblock_relink_to_newid(&collection_new->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &collection_new->id);
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those flags. */
|
||||
|
|
|
@ -669,55 +669,8 @@ void BKE_libblock_relink_ex(
|
|||
DEG_relations_tag_update(bmain);
|
||||
}
|
||||
|
||||
static void libblock_relink_to_newid(Main *bmain, ID *id);
|
||||
static int id_relink_to_newid_looper(LibraryIDLinkCallbackData *cb_data)
|
||||
{
|
||||
const int cb_flag = cb_data->cb_flag;
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED) {
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
ID **id_pointer = cb_data->id_pointer;
|
||||
ID *id = *id_pointer;
|
||||
if (id) {
|
||||
/* See: NEW_ID macro */
|
||||
if (id->newid) {
|
||||
BKE_library_update_ID_link_user(id->newid, id, cb_flag);
|
||||
id = id->newid;
|
||||
*id_pointer = id;
|
||||
}
|
||||
if (id->tag & LIB_TAG_NEW) {
|
||||
id->tag &= ~LIB_TAG_NEW;
|
||||
BKE_libblock_relink_to_newid(id);
|
||||
}
|
||||
}
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to #libblock_relink_ex,
|
||||
* but is remapping IDs to their newid value if non-NULL, in given \a id.
|
||||
*
|
||||
* Very specific usage, not sure we'll keep it on the long run,
|
||||
* currently only used in Object/Collection duplication code...
|
||||
*
|
||||
* WARNING: This is a deprecated version of this function, should not be used by new code. See
|
||||
* #BKE_libblock_relink_to_newid_new below.
|
||||
*/
|
||||
void BKE_libblock_relink_to_newid(ID *id)
|
||||
{
|
||||
if (ID_IS_LINKED(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BKE_library_foreach_ID_link(NULL, id, id_relink_to_newid_looper, NULL, 0);
|
||||
}
|
||||
|
||||
/* ************************
|
||||
* FIXME: Port all usages of #BKE_libblock_relink_to_newid to this
|
||||
* #BKE_libblock_relink_to_newid_new new code and remove old one.
|
||||
************************** */
|
||||
static void libblock_relink_to_newid_new(Main *bmain, ID *id);
|
||||
static int id_relink_to_newid_looper_new(LibraryIDLinkCallbackData *cb_data)
|
||||
{
|
||||
const int cb_flag = cb_data->cb_flag;
|
||||
if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) {
|
||||
|
@ -740,20 +693,20 @@ static int id_relink_to_newid_looper_new(LibraryIDLinkCallbackData *cb_data)
|
|||
}
|
||||
if (id->tag & LIB_TAG_NEW) {
|
||||
id->tag &= ~LIB_TAG_NEW;
|
||||
libblock_relink_to_newid_new(bmain, id);
|
||||
libblock_relink_to_newid(bmain, id);
|
||||
}
|
||||
}
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
static void libblock_relink_to_newid_new(Main *bmain, ID *id)
|
||||
static void libblock_relink_to_newid(Main *bmain, ID *id)
|
||||
{
|
||||
if (ID_IS_LINKED(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
id->tag &= ~LIB_TAG_NEW;
|
||||
BKE_library_foreach_ID_link(bmain, id, id_relink_to_newid_looper_new, NULL, 0);
|
||||
BKE_library_foreach_ID_link(bmain, id, id_relink_to_newid_looper, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -765,7 +718,7 @@ static void libblock_relink_to_newid_new(Main *bmain, ID *id)
|
|||
* Very specific usage, not sure we'll keep it on the long run,
|
||||
* currently only used in Object/Collection duplication code...
|
||||
*/
|
||||
void BKE_libblock_relink_to_newid_new(Main *bmain, ID *id)
|
||||
void BKE_libblock_relink_to_newid(Main *bmain, ID *id)
|
||||
{
|
||||
if (ID_IS_LINKED(id)) {
|
||||
return;
|
||||
|
@ -774,7 +727,7 @@ void BKE_libblock_relink_to_newid_new(Main *bmain, ID *id)
|
|||
BLI_assert(bmain->relations == NULL);
|
||||
|
||||
BKE_layer_collection_resync_forbid();
|
||||
libblock_relink_to_newid_new(bmain, id);
|
||||
libblock_relink_to_newid(bmain, id);
|
||||
BKE_layer_collection_resync_allow();
|
||||
BKE_main_collection_sync_remap(bmain);
|
||||
}
|
||||
|
|
|
@ -2858,7 +2858,7 @@ Object *BKE_object_duplicate(Main *bmain,
|
|||
|
||||
if (!is_subprocess) {
|
||||
/* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
|
||||
BKE_libblock_relink_to_newid(&obn->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &obn->id);
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those flags. */
|
||||
|
|
|
@ -1853,7 +1853,7 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
|
|||
|
||||
if (!is_subprocess) {
|
||||
/* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
|
||||
BKE_libblock_relink_to_newid(&sce_copy->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &sce_copy->id);
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those
|
||||
|
|
|
@ -2145,7 +2145,7 @@ static void copy_object_set_idnew(bContext *C)
|
|||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
||||
BKE_libblock_relink_to_newid(&ob->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &ob->id);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
|
@ -2378,7 +2378,7 @@ static void make_object_duplilist_real(bContext *C,
|
|||
Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
|
||||
|
||||
/* Remap new object to itself, and clear again newid pointer of orig object. */
|
||||
BKE_libblock_relink_to_newid(&ob_dst->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &ob_dst->id);
|
||||
|
||||
DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
|
||||
|
||||
|
@ -3375,7 +3375,7 @@ Base *ED_object_add_duplicate(
|
|||
ob = basen->object;
|
||||
|
||||
/* link own references to the newly duplicated data T26816. */
|
||||
BKE_libblock_relink_to_newid(&ob->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &ob->id);
|
||||
|
||||
/* DAG_relations_tag_update(bmain); */ /* caller must do */
|
||||
|
||||
|
|
|
@ -1685,18 +1685,20 @@ static bool single_data_needs_duplication(ID *id)
|
|||
return (id != NULL && (id->us > 1 || ID_IS_LINKED(id)));
|
||||
}
|
||||
|
||||
static void libblock_relink_collection(Collection *collection, const bool do_collection)
|
||||
static void libblock_relink_collection(Main *bmain,
|
||||
Collection *collection,
|
||||
const bool do_collection)
|
||||
{
|
||||
if (do_collection) {
|
||||
BKE_libblock_relink_to_newid(&collection->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &collection->id);
|
||||
}
|
||||
|
||||
for (CollectionObject *cob = collection->gobject.first; cob != NULL; cob = cob->next) {
|
||||
BKE_libblock_relink_to_newid(&cob->ob->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &cob->ob->id);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
|
||||
libblock_relink_collection(child->collection, true);
|
||||
libblock_relink_collection(bmain, child->collection, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1766,10 +1768,10 @@ static void single_object_users(
|
|||
single_object_users_collection(bmain, scene, master_collection, flag, copy_collections, true);
|
||||
|
||||
/* Will also handle the master collection. */
|
||||
BKE_libblock_relink_to_newid(&scene->id);
|
||||
BKE_libblock_relink_to_newid(bmain, &scene->id);
|
||||
|
||||
/* Collection and object pointers in collections */
|
||||
libblock_relink_collection(scene->master_collection, false);
|
||||
libblock_relink_collection(bmain, scene->master_collection, false);
|
||||
|
||||
/* We also have to handle runtime things in UI. */
|
||||
if (v3d) {
|
||||
|
|
|
@ -812,7 +812,7 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
|
|||
|
||||
BLI_assert(!ID_IS_LINKED(id));
|
||||
|
||||
BKE_libblock_relink_to_newid_new(bmain, id);
|
||||
BKE_libblock_relink_to_newid(bmain, id);
|
||||
}
|
||||
|
||||
/* Remove linked IDs when a local existing data has been reused instead. */
|
||||
|
|
Loading…
Reference in New Issue