[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35299] trunk/blender/source/blender/ python/intern/bpy_rna.c: minor fixes to weakref validation before making bigger changes
Campbell Barton
ideasman42 at gmail.com
Wed Mar 2 07:56:21 CET 2011
Revision: 35299
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35299
Author: campbellbarton
Date: 2011-03-02 06:56:21 +0000 (Wed, 02 Mar 2011)
Log Message:
-----------
minor fixes to weakref validation before making bigger changes
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2011-03-02 06:47:08 UTC (rev 35298)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2011-03-02 06:56:21 UTC (rev 35299)
@@ -40,7 +40,7 @@
#include "bpy_util.h"
#include "bpy_rna_callback.h"
-#ifdef USE_PYRNA_INVALIDATE_GC
+#ifdef USE_PYRNA_INVALIDATE_WEAKREF
#include "MEM_guardedalloc.h"
#endif
@@ -50,7 +50,7 @@
#include "BLI_math_rotation.h"
#include "BLI_utildefines.h"
-#ifdef USE_PYRNA_INVALIDATE_GC
+#ifdef USE_PYRNA_INVALIDATE_WEAKREF
#include "BLI_ghash.h"
#endif
@@ -171,18 +171,21 @@
PyObject *weakinfo_list= id_weakref_pool_get(id); /* new or existing */
PyObject *weakinfo_pair= PyTuple_New(2);
PyTuple_SET_ITEM(weakinfo_pair, 0, weakinfo_list);
- Py_INCREF(weakinfo_list);
- PyTuple_SET_ITEM(weakinfo_pair, 1, PyCapsule_New(id, NULL, NULL));
+ Py_INCREF(weakinfo_list); /* increase the reference because the ghash owns as well as the tuple */
+ PyTuple_SET_ITEM(weakinfo_pair, 1, PyCapsule_New(id, NULL, NULL)); /* only tuple owns */
weakref_cb_py= PyCFunction_New(&id_free_weakref_cb_def, weakinfo_pair);
- Py_DECREF(weakinfo_pair); /* function' 'self' now owns weakinfo_list now */
+ Py_DECREF(weakinfo_pair); /* functions 'self' owns 'weakinfo_pair' now */
+
/* add weakref to weakinfo_list list */
weakref= PyWeakref_NewRef((PyObject *)pyrna, weakref_cb_py);
- Py_DECREF(weakref_cb_py); /* function owned by the weakref now */
+// // EEK!!!, this causes an error if its added back with UV layout export!!!
+// Py_DECREF(weakref_cb_py); /* function owned by the weakref now */
+
/* important to add at the end, since first removal looks at the end */
PyList_Append(weakinfo_list, weakref);
- Py_DECREF(weakref);
+ Py_DECREF(weakref); /* list owns weakref */
}
static void id_release_weakref(struct ID *id);
More information about the Bf-blender-cvs
mailing list