From b97c567c1df1e5c38833c4af8a95962e0ece4c61 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 21 Nov 2016 15:19:34 +0100 Subject: Fix two very bad issues in new ID.make_local RNA function. I) `clear_proxy` parameter was not assigned to parm in RNA define code, so 'pyfunc optional' flag was set to `new_id` parameter of `user_remap` func - super ugly! II) `clear_proxy` parameter itself, when set to False, would allow to leave .blend file in invalid state (more than one proxy of same object), this should never, ever be allowed in RNA API imho. Left the PAI untouched for now, just disabled any effect from this parameter (hence always clearing proxy when copying). --- source/blender/makesrna/intern/rna_ID.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 5174c957834..b5015c3fbde 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -348,13 +348,21 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id) } } -static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, int clear_proxy) +static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, int UNUSED(clear_proxy)) { + /* XXX This is *very, very bad*, since it may leave Main in invalid state (two objects, one local and one linked, + * proxies of same reference linked object). + * This can be allowed in C code (with extensive warning and documentation), + * but is totally fully forbidden in our RNA API! + * So disabling for now. */ +#if 0 /* Special case, as we can't rely on id_make_local(); it clears proxies. */ if (!clear_proxy && GS(self->name) == ID_OB) { BKE_object_make_local_ex(bmain, (Object *)self, false, clear_proxy); } - else { + else +#endif + { id_make_local(bmain, self, false, false); } @@ -1018,9 +1026,7 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_function_ui_description(func, "Make this datablock local, return local one " "(may be a copy of the original, in case it is also indirectly used)"); RNA_def_function_flag(func, FUNC_USE_MAIN); - RNA_def_boolean(func, "clear_proxy", true, "", - "Whether to clear proxies (the default behavior); can cause proxies to be duplicated" - " when still referred to from another library"); + parm = RNA_def_boolean(func, "clear_proxy", true, "", "DO NOT USE! - has no effect at all"); RNA_def_property_flag(parm, PROP_PYFUNC_OPTIONAL); parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied"); RNA_def_function_return(func, parm); -- cgit v1.2.3