Commit: 9686721af5b6fe728fd2caa42dd637a53a521d52
Author: Sybren A. Stüvel
Date:   Wed Nov 9 12:11:48 2016 +0100
Branches: temp-sybren-bpy-make-local
https://developer.blender.org/rB9686721af5b6fe728fd2caa42dd637a53a521d52

Moved bpy.data.make_local(…) to bpy.types.ID.make_local(…)

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

M       release/scripts/modules/bpy_types.py
M       source/blender/makesrna/intern/rna_ID.c
M       source/blender/python/intern/bpy_rna_id_collection.c

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

diff --git a/release/scripts/modules/bpy_types.py 
b/release/scripts/modules/bpy_types.py
index 71705ff..d64acd2 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -28,7 +28,6 @@ StructMetaPropGroup = bpy_types.bpy_struct_meta_idprop
 bpy_types.BlendDataLibraries.load = _bpy._library_load
 bpy_types.BlendDataLibraries.write = _bpy._library_write
 bpy_types.BlendData.user_map = _bpy._rna_id_collection_user_map
-bpy_types.BlendData.make_local = _bpy._rna_id_collection_make_local
 
 
 class Context(StructRNA):
diff --git a/source/blender/makesrna/intern/rna_ID.c 
b/source/blender/makesrna/intern/rna_ID.c
index 280ad4a..f264c87 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -35,6 +35,7 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_icons.h"
+#include "BKE_object.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -347,6 +348,18 @@ 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)
+{
+       /* 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 {
+               id_make_local(bmain, _self, false, false);
+       }
+}
+
+
 static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
 {
        AnimData *adt = BKE_animdata_add_id(id);
@@ -999,6 +1012,20 @@ static void rna_def_ID(BlenderRNA *brna)
        parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
        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_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"
+                       " when still referred to from another library");
+       RNA_def_property_flag(parm, PROP_PYFUNC_OPTIONAL);
+
        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");
        parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c 
b/source/blender/python/intern/bpy_rna_id_collection.c
index bf030eb..8c821ce 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -292,61 +292,13 @@ error:
 
 }
 
-PyDoc_STRVAR(bpy_make_local_doc,
-".. method:: make_local(idblock, clear_proxy=True)\n"
-"\n"
-"   Makes the given ID datablock local.\n"
-"\n"
-"   Note that this will not work reliably when the idblock is referenced from 
a library.\n"
-"   It is the caller's responsibility to ensure a proper state. Use with 
care.\n"
-"\n"
-"   :arg idblock: The data-blocks that will be made local.\n"
-"   :type idblock: bpy.types.ID\n"
-"   :arg clear_proxy: Whether to clear proxies (default) or not. Can cause 
proxies to be\n"
-"                     duplicated when still referred to from another 
library.\n"
-"   :type clear_proxy: bool\n"
-);
-static PyObject *bpy_make_local(PyObject *UNUSED(self), PyObject *args, 
PyObject *kwds)
-{
-       Main *bmain = G.main;  /* XXX see note in bpy_user_map() about this 
being ugly. */
-       ID *id;
-       static const char *kwlist[] = {"idblock", "clear_proxy", NULL};
-       PyObject *py_id;
-       bool clear_proxy=true;
-
-       if (!PyArg_ParseTupleAndKeywords(
-               args, kwds, "O|$p:make_local", (char **)kwlist,
-               &py_id, &clear_proxy))
-       {
-               return NULL;
-       }
-
-       if (!pyrna_id_FromPyObject(py_id, &id)) {
-               PyErr_SetString(PyExc_ValueError, "idblock parameter is not 
actually an ID datablock");
-               return NULL;
-       }
-
-       /* Special case, as we can't rely on id_make_local(); it clears 
proxies. */
-       if (!clear_proxy && GS(id->name) == ID_OB) {
-               BKE_object_make_local_ex(bmain, (Object *)id, false, 
clear_proxy);
-       }
-       else {
-               id_make_local(bmain, id, false, false);
-       }
-
-       Py_RETURN_NONE;
-}
-
 
 int BPY_rna_id_collection_module(PyObject *mod_par)
 {
        static PyMethodDef user_map = {
            "user_map", (PyCFunction)bpy_user_map, METH_VARARGS | 
METH_KEYWORDS, bpy_user_map_doc};
-       static PyMethodDef make_local_map = {
-           "make_local", (PyCFunction)bpy_make_local, METH_VARARGS | 
METH_KEYWORDS, bpy_make_local_doc};
 
        PyModule_AddObject(mod_par, "_rna_id_collection_user_map", 
PyCFunction_New(&user_map, NULL));
-       PyModule_AddObject(mod_par, "_rna_id_collection_make_local", 
PyCFunction_New(&make_local_map, NULL));
 
        return 0;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to