[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44383] trunk/blender/source/blender/ python/bmesh/bmesh_py_types.c: bmesh py api - ensure data layers to store bmesh pointers exist - removing all elements could free them for eg .
Campbell Barton
ideasman42 at gmail.com
Thu Feb 23 18:22:40 CET 2012
Revision: 44383
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44383
Author: campbellbarton
Date: 2012-02-23 17:22:37 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
bmesh py api - ensure data layers to store bmesh pointers exist - removing all elements could free them for eg.
Modified Paths:
--------------
trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-02-23 17:14:53 UTC (rev 44382)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-02-23 17:22:37 UTC (rev 44383)
@@ -1635,6 +1635,12 @@
void **ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR);
+ /* bmesh may free layers, ensure we have one to store ourself */
+ if (UNLIKELY(ptr == NULL)) {
+ BM_data_layer_add(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
+ ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR);
+ }
+
if (*ptr != NULL) {
self = *ptr;
Py_INCREF(self);
@@ -1655,6 +1661,12 @@
void **ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR);
+ /* bmesh may free layers, ensure we have one to store ourself */
+ if (UNLIKELY(ptr == NULL)) {
+ BM_data_layer_add(bm, &bm->edata, CD_BM_ELEM_PYPTR);
+ ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR);
+ }
+
if (*ptr != NULL) {
self = *ptr;
Py_INCREF(self);
@@ -1675,6 +1687,12 @@
void **ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR);
+ /* bmesh may free layers, ensure we have one to store ourself */
+ if (UNLIKELY(ptr == NULL)) {
+ BM_data_layer_add(bm, &bm->pdata, CD_BM_ELEM_PYPTR);
+ ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR);
+ }
+
if (*ptr != NULL) {
self = *ptr;
Py_INCREF(self);
@@ -1695,6 +1713,12 @@
void **ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR);
+ /* bmesh may free layers, ensure we have one to store ourself */
+ if (UNLIKELY(ptr == NULL)) {
+ BM_data_layer_add(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
+ ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR);
+ }
+
if (*ptr != NULL) {
self = *ptr;
Py_INCREF(self);
More information about the Bf-blender-cvs
mailing list