[Bf-blender-cvs] [a40ccde4052] master: Fix logic for calling PyObject_GC_UnTrack

Campbell Barton noreply at git.blender.org
Thu Mar 4 05:18:52 CET 2021


Commit: a40ccde405211b82eed8259b1afaa43dc41fa6a6
Author: Campbell Barton
Date:   Thu Mar 4 15:06:15 2021 +1100
Branches: master
https://developer.blender.org/rBa40ccde405211b82eed8259b1afaa43dc41fa6a6

Fix logic for calling PyObject_GC_UnTrack

All tracked objects need a matching un-track,
also remove redundant Py_XDECREF call.

===================================================================

M	source/blender/python/gpu/gpu_py_batch.c
M	source/blender/python/gpu/gpu_py_buffer.c
M	source/blender/python/intern/bpy_props.c

===================================================================

diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index ef795268158..8e803350b53 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -279,8 +279,8 @@ static void pygpu_batch__tp_dealloc(BPyGPUBatch *self)
   GPU_batch_discard(self->batch);
 
 #ifdef USE_GPU_PY_REFERENCES
+  PyObject_GC_UnTrack(self);
   if (self->references) {
-    PyObject_GC_UnTrack(self);
     pygpu_batch__tp_clear(self);
     Py_XDECREF(self->references);
   }
diff --git a/source/blender/python/gpu/gpu_py_buffer.c b/source/blender/python/gpu/gpu_py_buffer.c
index b89d2c6a69f..420a7873517 100644
--- a/source/blender/python/gpu/gpu_py_buffer.c
+++ b/source/blender/python/gpu/gpu_py_buffer.c
@@ -202,8 +202,7 @@ static void pygpu_buffer__tp_dealloc(BPyGPUBuffer *self)
 {
   if (self->parent) {
     PyObject_GC_UnTrack(self);
-    pygpu_buffer__tp_clear(self);
-    Py_XDECREF(self->parent);
+    Py_CLEAR(self->parent);
   }
   else {
     MEM_freeN(self->buf.as_void);
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index b2812e0eba7..246387486be 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -203,10 +203,8 @@ static const EnumPropertyItem property_subtype_array_items[] = {
 
 static void bpy_prop_deferred_dealloc(BPy_PropDeferred *self)
 {
-  if (self->kw) {
-    PyObject_GC_UnTrack(self);
-    Py_CLEAR(self->kw);
-  }
+  PyObject_GC_UnTrack(self);
+  Py_CLEAR(self->kw);
   PyObject_GC_Del(self);
 }



More information about the Bf-blender-cvs mailing list