I’ve discovered several cases of broken ref counter (in particular, just ungrouping nodes or creating new material).
It seems like refcounters should be handled in BKE_id_copy_ex
by this code:
/* Update ID refcount, remap pointers to self in new ID. */
struct IDCopyLibManagementData data = {
.id_src = id,
.id_dst = *r_newid,
.flag = flag,
};
BKE_library_foreach_ID_link(bmain, *r_newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
But to make it work, the id_copy_libmanagement_cb
should be called with IDWALK_CB_USER
set in cb_flag
:
/* Increase used IDs refcount if needed and required. */
if ((data->flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0 && (cb_flag & IDWALK_CB_USER)) {
id_us_plus(id);
}
And it’s is not the case in BKE_id_copy
. And it’s never the case.
Do I miss something?