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>2012-11-01 19:56:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-01 19:56:42 +0400
commitf4e5404e4ae1bf0c5c45220f87e981fbc4c3ab98 (patch)
treeff46e4486c2c137aff2cd5196835d21bd5376b7d /source/blender/python
parent818e9ff88d84f85ad729b8d7839ead21568cff20 (diff)
fix for long standing problem with blender 2.5x py api.
Removing data then accessing would allow invalid memory access and often crash. Example: import bpy image = bpy.data.images.new(name="a", width=5, height=5) bpy.data.images.remove(image) print(image.name) Now access to the removed data raises an error: ReferenceError: StructRNA of type Image has been removed This is the same level of error checking that was done in blender 2.4x but was made difficult by RNA functions not having access to the PyObject's.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index db9ff2e1a32..3b57e550c28 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -121,8 +121,7 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self)
void pyrna_invalidate(BPy_DummyPointerRNA *self)
{
- self->ptr.type = NULL; /* this is checked for validity */
- self->ptr.id.data = NULL; /* should not be needed but prevent bad pointer access, just in case */
+ RNA_POINTER_INVALIDATE(&self->ptr);
}
#ifdef USE_PYRNA_INVALIDATE_GC
@@ -1776,10 +1775,21 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
if (data) {
if (flag & PROP_RNAPTR) {
- if (value == Py_None)
- memset(data, 0, sizeof(PointerRNA));
- else
- *((PointerRNA *)data) = param->ptr;
+ if (flag & PROP_THICK_WRAP) {
+ if (value == Py_None)
+ memset(data, 0, sizeof(PointerRNA));
+ else
+ *((PointerRNA *)data) = param->ptr;
+ }
+ else {
+ /* for function calls, we sometimes want to pass the 'ptr' directly,
+ * watch out that it remains valid!, possibly we could support this later if needed */
+ BLI_assert(value_new == NULL);
+ if (value == Py_None)
+ *((void **)data) = NULL;
+ else
+ *((PointerRNA **)data) = &param->ptr;
+ }
}
else if (value == Py_None) {
*((void **)data) = NULL;