diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-01 19:56:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-01 19:56:42 +0400 |
commit | f4e5404e4ae1bf0c5c45220f87e981fbc4c3ab98 (patch) | |
tree | ff46e4486c2c137aff2cd5196835d21bd5376b7d /source/blender/makesrna/intern/makesrna.c | |
parent | 818e9ff88d84f85ad729b8d7839ead21568cff20 (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/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 2d0b64f8df5..8c7e4a53163 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2095,6 +2095,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA /* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */ else if (type == PROP_POINTER || dparm->prop->arraydimension) ptrstr = "*"; + else if ((type == PROP_POINTER) && (flag & PROP_RNAPTR) && !(flag & PROP_THICK_WRAP)) + ptrstr = "*"; /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack, * but type name for string props is already char*, so leave empty */ else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) @@ -2146,6 +2148,10 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA ptrstr = "**"; valstr = "*"; } + else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) { + ptrstr = "**"; + valstr = "*"; + } else if (type == PROP_POINTER || dparm->prop->arraydimension) { ptrstr = "*"; valstr = ""; |