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>2011-03-01 17:53:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-01 17:53:26 +0300
commit623822626a954fe9f83f18af4b3699c6e80b5313 (patch)
tree54afb70ab229403aa532e7f38cad26c6eebbc188 /source/blender/python/intern/bpy_rna.h
parentf0f639f8b8414a9574a12b4fcf5b76549524f540 (diff)
Py/RNA Stability: don't allow python to reference freed ID's and crash.
Second method for not having python crash blender on invalid access (ifdef'd out ATM, so no functional change). This uses a weakref list per ID, and invalidates all members of that list when the ID is freed. the list is not stores in the ID pointer but using a hash table since storing python in DNA data is not acceptable. This is more correct then the previous method but shows down execution of scripts significantly since its always adding and removing from lists when data is created and freed.
Diffstat (limited to 'source/blender/python/intern/bpy_rna.h')
-rw-r--r--source/blender/python/intern/bpy_rna.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 8d9fabf5627..be877344c48 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -44,12 +44,25 @@ extern PyTypeObject pyrna_prop_collection_Type;
#define BPy_PropertyRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_prop_Type))
#define BPy_PropertyRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_prop_Type)
-/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
-// #define USE_PYRNA_INVALIDATE_GC
-
/* play it safe and keep optional for now, need to test further now this affects looping on 10000's of verts for eg. */
// #define USE_WEAKREFS
+/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
+//#define USE_PYRNA_INVALIDATE_GC
+
+/* different method */
+//#define USE_PYRNA_INVALIDATE_WEAKREF
+
+
+/* sanity checks on above defs */
+#if defined(USE_PYRNA_INVALIDATE_WEAKREF) && !defined(USE_WEAKREFS)
+#define USE_WEAKREFS
+#endif
+
+#if defined(USE_PYRNA_INVALIDATE_GC) && defined(USE_PYRNA_INVALIDATE_WEAKREF)
+#error "Only 1 reference check method at a time!"
+#endif
+
typedef struct {
PyObject_HEAD /* required python macro */
PointerRNA ptr;