IDRemap: Add option to also remap internal runtime ID pointers.
In some cases (advanced, low-level), we also want to remap pointers like `ID.newid` or `ID.orig_id`. Only known case currently is `id_delete`, to avoid leaving potential access to freed memory. See next commit and T86501.
This commit is contained in:
parent
fd4c01a75c
commit
4781ab0969
|
@ -78,6 +78,13 @@ enum {
|
|||
ID_REMAP_SKIP_OVERRIDE_LIBRARY = 1 << 5,
|
||||
/** Don't touch the user count (use for low level actions such as swapping pointers). */
|
||||
ID_REMAP_SKIP_USER_CLEAR = 1 << 6,
|
||||
/**
|
||||
* Force internal ID runtime pointers (like `ID.newid`, `ID.orig_id` etc.) to also be processed.
|
||||
* This should only be needed in some very specific cases, typically only BKE ID management code
|
||||
* should need it (e.g. required from `id_delete` to ensure no runtime pointer remains using
|
||||
* freed ones).
|
||||
*/
|
||||
ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS = 1 << 7,
|
||||
};
|
||||
|
||||
/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately,
|
||||
|
|
|
@ -373,9 +373,12 @@ static void libblock_remap_data(
|
|||
Main *bmain, ID *id, ID *old_id, ID *new_id, const short remap_flags, IDRemap *r_id_remap_data)
|
||||
{
|
||||
IDRemap id_remap_data;
|
||||
const int foreach_id_flags = (remap_flags & ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE) != 0 ?
|
||||
IDWALK_NO_INDIRECT_PROXY_DATA_USAGE :
|
||||
IDWALK_NOP;
|
||||
const int foreach_id_flags = ((remap_flags & ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE) != 0 ?
|
||||
IDWALK_NO_INDIRECT_PROXY_DATA_USAGE :
|
||||
IDWALK_NOP) |
|
||||
((remap_flags & ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS) != 0 ?
|
||||
IDWALK_DO_INTERNAL_RUNTIME_POINTERS :
|
||||
IDWALK_NOP);
|
||||
|
||||
if (r_id_remap_data == NULL) {
|
||||
r_id_remap_data = &id_remap_data;
|
||||
|
|
Loading…
Reference in New Issue