bmesh py api - ensure data layers to store bmesh pointers exist - removing all elements could free them for eg.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user