[Bf-blender-cvs] [52fcba6] temp-sybren-bpy-make-local: ID.make_local(): handled mont29's feedback

Sybren A. Stüvel noreply at git.blender.org
Wed Nov 9 15:53:47 CET 2016


Commit: 52fcba6e37a1743639e02b2bb1ba2eee1e7fc86d
Author: Sybren A. Stüvel
Date:   Wed Nov 9 15:49:21 2016 +0100
Branches: temp-sybren-bpy-make-local
https://developer.blender.org/rB52fcba6e37a1743639e02b2bb1ba2eee1e7fc86d

ID.make_local(): handled mont29's feedback

- returning 'self' or 'self->newid'
- rewording RNA descriptions

===================================================================

M	source/blender/makesrna/intern/rna_ID.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index f264c87..5174c95 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -348,15 +348,17 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
 	}
 }
 
-static void 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 clear_proxy)
 {
 	/* 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);
+	if (!clear_proxy && GS(self->name) == ID_OB) {
+		BKE_object_make_local_ex(bmain, (Object *)self, false, clear_proxy);
 	}
 	else {
-		id_make_local(bmain, _self, false, false);
+		id_make_local(bmain, self, false, false);
 	}
+
+	return self->newid ? self->newid : self;
 }
 
 
@@ -1013,18 +1015,15 @@ static void rna_def_ID(BlenderRNA *brna)
 	RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
 
 	func = RNA_def_function(srna, "make_local", "rna_ID_make_local");
-	RNA_def_function_ui_description(
-	            func,
-	            "Makes the given ID datablock local.\n"
-	            "\n"
-	            "      Note that this will not work reliably when the idblock is referenced from a library.\n"
-	            "      Also, linked objects cannot refer to local data.\n"
-	            "      It is the caller's responsibility to ensure a proper state. Use with care.\n\n");
+	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 behaviour). Can cause proxies to be duplicated"
+	                "Whether to clear proxies (the default behavior); can cause proxies to be duplicated"
 	                " when still referred to from another library");
 	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);
 
 	func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
 	RNA_def_function_ui_description(func, "Count the number of times that ID uses/references given one");




More information about the Bf-blender-cvs mailing list