ifdef out support for for python owning and freeing BPy_StructRNA because this is...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 5 Aug 2011 16:29:38 +0000 (16:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 5 Aug 2011 16:29:38 +0000 (16:29 +0000)
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna.h

index 4a17c45ae3884bcf3904862afe5d8c4c8f66949f..4b05a9c0c728c5802cee04d0e1e5058c7fde402a 100644 (file)
@@ -397,7 +397,9 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
 
        
        pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
+#ifdef PYRNA_FREE_SUPPORT
        pyrna->freeptr= TRUE;
+#endif
        return (PyObject *)pyrna;
 }
 
index d517205e2fe3cdbb387e479de3eb20defb45015f..4447a0476f4f87c8dec518f8eae67fc8d20bd69c 100644 (file)
@@ -957,11 +957,13 @@ static int pyrna_struct_clear(BPy_StructRNA *self)
 /* use our own dealloc so we can free a property if we use one */
 static void pyrna_struct_dealloc(BPy_StructRNA *self)
 {
+#ifdef PYRNA_FREE_SUPPORT
        if (self->freeptr && self->ptr.data) {
                IDP_FreeProperty(self->ptr.data);
                MEM_freeN(self->ptr.data);
                self->ptr.data= NULL;
        }
+#endif /* PYRNA_FREE_SUPPORT */
 
 #ifdef USE_WEAKREFS
        if (self->in_weakreflist != NULL) {
@@ -5495,7 +5497,9 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
        }
 
        pyrna->ptr= *ptr;
+#ifdef PYRNA_FREE_SUPPORT
        pyrna->freeptr= FALSE;
+#endif
 
 #ifdef USE_PYRNA_STRUCT_REFERENCE
        pyrna->reference= NULL;
index 3796984ea81923532171d9bc548c6c3faa7eb3c1..30f6c02115aa70b51034ed46281e48b4ac43459c 100644 (file)
 #if defined(USE_PYRNA_INVALIDATE_GC) && defined(USE_PYRNA_INVALIDATE_WEAKREF)
 #error "Only 1 reference check method at a time!"
 #endif
+
+/* only used by operator introspection get_rna(), this is only used for doc gen
+ * so prefer the leak to the memory bloat for now. */
+// #define PYRNA_FREE_SUPPORT
+
 /* --- end bpy build options --- */
 
 struct ID;
@@ -108,7 +113,10 @@ typedef struct {
         * hold onto the collection iterator to prevent it from freeing allocated data we may use */
        PyObject *reference;
 #endif /* !USE_PYRNA_STRUCT_REFERENCE */
+
+#ifdef PYRNA_FREE_SUPPORT
        int freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */
+#endif /* PYRNA_FREE_SUPPORT */
 } BPy_StructRNA;
 
 typedef struct {