Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-23 21:22:37 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-23 21:22:37 +0400
commit6871860cfe4b7b706a90e57928e7a85eb9de2aad (patch)
treea262f4f3e52d8720c902ce671060a94d8ea84f00 /source/blender/python
parent310af7d73f96d4b58665ad149ac6ee0ac52928d2 (diff)
bmesh py api - ensure data layers to store bmesh pointers exist - removing all elements could free them for eg.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 83bda8c1343..3d7c051b6ea 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1635,6 +1635,12 @@ PyObject *BPy_BMVert_CreatePyObject(BMesh *bm, BMVert *v)
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 @@ PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e)
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 @@ PyObject *BPy_BMFace_CreatePyObject(BMesh *bm, BMFace *f)
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 @@ PyObject *BPy_BMLoop_CreatePyObject(BMesh *bm, BMLoop *l)
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);