Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-03-08 17:01:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-08 17:01:31 +0300
commit9e0921497912cbfe9846358d1cb1220f88315f80 (patch)
tree093e2de27514b297de63ce6ea1597401507622ab /source/blender/python/intern/bpy_rna.c
parentcfd11af9819433c5b83359b72f002fcd59fdc1ab (diff)
PyAPI: add bpy.types.BlendFile.temp_data for temporary library loading
This adds support for creating a `BlendFile` (internally called `Main`), which is limited to a context. Temporary data can now be created which can then use `.libraries.load()` the same as with `bpy.data`. To prevent errors caused by mixing the temporary ID's with data in `bpy.data` they are tagged as temporary so they can't be assigned to properties, however they can be passed as arguments to functions. Reviewed By: mont29, sybren Ref D10612
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r--source/blender/python/intern/bpy_rna.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index ecaa5791e38..7a43c9cb997 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2061,6 +2061,19 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
+
+ if (value_owner_id->tag & LIB_TAG_TEMP_MAIN) {
+ /* Allow passing temporary ID's to functions, but not attribute assignment. */
+ if (ptr->type != &RNA_Function) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s ID type assignment is temporary, can't assign",
+ error_prefix,
+ RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
+ Py_XDECREF(value_new);
+ return -1;
+ }
+ }
}
}