From 8140c76ac6142cd7182eacd866744017929a4a69 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Jan 2009 15:29:09 +0000 Subject: RNA: fix crash in python code, forgot to update this part in a previous commit. --- source/blender/python/intern/bpy_operator.c | 4 +++- source/blender/python/intern/bpy_rna.c | 10 +++++----- source/blender/python/intern/bpy_rna.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 061c43c4773..f800b7d0d04 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -164,7 +164,9 @@ PyObject *pyop_func_get_rna(BPy_OperatorFunc *self) pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); /* were not really using &ptr, overwite next */ /* XXX POINTER - if this 'ot' is python generated, it could be free'd */ - RNA_pointer_create(NULL, NULL, ot->srna, &pyrna->properties, &pyrna->ptr); + RNA_pointer_create(NULL, ot->srna, NULL, &pyrna->ptr); + pyrna->freeptr= 1; + return (PyObject *)pyrna; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index a8409976b73..7ad40d3dcd3 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -63,10 +63,10 @@ static long pyrna_struct_hash( BPy_StructRNA * self ) static void pyrna_struct_dealloc( BPy_StructRNA * self ) { /* Note!! for some weired reason calling PyObject_DEL() directly crashes blender! */ - if (self->properties) { - IDP_FreeProperty(self->properties); - MEM_freeN(self->properties); - self->properties= NULL; + if (self->freeptr && self->ptr.data) { + IDP_FreeProperty(self->ptr.data); + MEM_freeN(self->ptr.data); + self->ptr.data= NULL; } ((PyObject *)self)->ob_type->tp_free(self); @@ -1135,7 +1135,7 @@ PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr ) } pyrna->ptr= *ptr; - pyrna->properties= NULL; + pyrna->freeptr= 0; return ( PyObject * ) pyrna; } diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 8f21e6d80c8..73272eac6e8 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -36,7 +36,7 @@ extern PyTypeObject pyrna_prop_Type; typedef struct { PyObject_VAR_HEAD /* required python macro */ PointerRNA ptr; - IDProperty *properties; /* needed in some cases for RNA_pointer_create(), free when deallocing */ + int freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */ } BPy_StructRNA; typedef struct { -- cgit v1.2.3