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>2017-12-11 10:37:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-12-11 10:37:54 +0300
commitdd4e0cd3e30a88657981064c3f8fcd81612d9394 (patch)
tree341da6965d0831bca04de682ca64369c1e707590 /source/blender/makesrna/intern/rna_ID.c
parentc5689851186392407eab3ce3801db3270ce84cb6 (diff)
DNA/RNA: add 'py_instance' for ID types
Avoid creating new Python instances every time a scene, object, mesh .. etc are accessed. Also resolves crashes T28724, T53530 although it's only valid for ID types, not modifiers vertices etc. Back-ported from blender2.8 branch.
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 9d42ba55ecc..9205e15671b 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -387,6 +387,14 @@ static void rna_ID_animation_data_free(ID *id, Main *bmain)
DAG_relations_tag_update(bmain);
}
+#ifdef WITH_PYTHON
+void **rna_ID_instance(PointerRNA *ptr)
+{
+ ID *id = (ID *)ptr->data;
+ return &id->py_instance;
+}
+#endif
+
static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
IDProperty *prop = (IDProperty *)ptr->data;
@@ -1064,6 +1072,10 @@ static void rna_def_ID(BlenderRNA *brna)
"Tag the ID to update its display data, "
"e.g. when calling :class:`bpy.types.Scene.update`");
RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform");
+
+#ifdef WITH_PYTHON
+ RNA_def_struct_register_funcs(srna, NULL, NULL, "rna_ID_instance");
+#endif
}
static void rna_def_library(BlenderRNA *brna)