RNA/BPY API: Add clear_liboverride option to ID.make_local.

This function had the exacyt same behavior as the 'UI' operators, make
local invoqued on a linked liboverride would make the data local, but
would not clear the liboverride data from it. User then needs to call
this operation again if they want to remove that liboverride data.

The new `clear_liboverride` parameter to `ID.make_local` forces always
clearing any liboverride data, and allows to make a linked liboverride
fully local with a single call.

This option is kept disabled by default, to ensure default behavior
remains unchanged.
This commit is contained in:
Bastien Montagne
2024-01-09 19:37:55 +01:00
parent e6da277918
commit f88595e428

View File

@@ -1077,7 +1077,7 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
}
}
static ID *rna_ID_make_local(ID *self, Main *bmain, bool /*clear_proxy*/)
static ID *rna_ID_make_local(ID *self, Main *bmain, bool /*clear_proxy*/, bool clear_liboverride)
{
if (ID_IS_LINKED(self)) {
BKE_lib_id_make_local(bmain, self, 0);
@@ -1088,6 +1088,11 @@ static ID *rna_ID_make_local(ID *self, Main *bmain, bool /*clear_proxy*/)
ID *ret_id = self->newid ? self->newid : self;
BKE_id_newptr_and_tag_clear(self);
if (clear_liboverride && ID_IS_OVERRIDE_LIBRARY_REAL(ret_id)) {
BKE_lib_override_library_make_local(bmain, ret_id);
}
return ret_id;
}
@@ -2414,6 +2419,11 @@ static void rna_def_ID(BlenderRNA *brna)
"(may be a copy of the original, in case it is also indirectly used)");
RNA_def_function_flag(func, FUNC_USE_MAIN);
parm = RNA_def_boolean(func, "clear_proxy", true, "", "Deprecated, has no effect");
parm = RNA_def_boolean(func,
"clear_liboverride",
false,
"",
"Remove potential library override data from the newly made local data");
parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied");
RNA_def_function_return(func, parm);