IDManagement: Add option to 'make local' code to clear liboverride data.

In some cases, when making a linked liboverride data local, the
liboverride data should be preserved (and therefore produce a local
liboverride data).

However, it implies that the data is not really, fully made local, since
it has (critical) dependencies to linked data.

This new option allows 'make local' code to also clear any liboverride
data in the processed ID, making it effectively fully local.

Preliminary step to solve #109004.
This commit is contained in:
Bastien Montagne 2023-06-27 11:49:56 +02:00
parent 597f9abcfa
commit daf414b48e
2 changed files with 10 additions and 1 deletions

View File

@ -378,6 +378,9 @@ enum {
/** Clear asset data (in case the ID can actually be made local, in copy case asset data is never
* copied over). */
LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR = 1 << 3,
/** Clear any liboverride data as part of making this linked data local. */
LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR = 1 << 4,
};
/**

View File

@ -506,10 +506,16 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
if (force_local) {
BKE_lib_id_clear_library_data(bmain, id, flags);
if ((flags & LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR) != 0) {
BKE_lib_override_library_make_local(id);
}
BKE_lib_id_expand_local(bmain, id, flags);
}
else if (force_copy) {
ID *id_new = BKE_id_copy(bmain, id);
const int copy_flags =
(LIB_ID_COPY_DEFAULT |
((flags & LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR) != 0 ? LIB_ID_COPY_NO_LIB_OVERRIDE : 0));
ID *id_new = BKE_id_copy_ex(bmain, id, NULL, copy_flags);
/* Should not fail in expected use cases,
* but a few ID types cannot be copied (LIB, WM, SCR...). */