[Bf-blender-cvs] [8661ab12a68] master: Fix BMesh PyAPI internal flag clearing logic
Campbell Barton
noreply at git.blender.org
Tue Oct 24 07:49:47 CEST 2017
Commit: 8661ab12a681efc17c7304c03c322a39a5d241ef
Author: Campbell Barton
Date: Tue Oct 24 16:52:54 2017 +1100
Branches: master
https://developer.blender.org/rB8661ab12a681efc17c7304c03c322a39a5d241ef
Fix BMesh PyAPI internal flag clearing logic
Would leave the flag set on raising an exception.
===================================================================
M source/blender/python/bmesh/bmesh_py_types.c
===================================================================
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 9f184059a49..6ab5ebf3c81 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -3868,7 +3868,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
BMesh *bm = (r_bm && *r_bm) ? *r_bm : NULL;
PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
const Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq_fast);
- Py_ssize_t i;
+ Py_ssize_t i, i_last_dirty = PY_SSIZE_T_MAX;
BPy_BMElem *item;
BMElem **alloc;
@@ -3917,6 +3917,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
if (do_unique_check) {
BM_elem_flag_enable(item->ele, BM_ELEM_INTERNAL_TAG);
+ i_last_dirty = i;
}
}
@@ -3933,6 +3934,8 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
}
if (ok == false) {
+ /* Cleared above. */
+ i_last_dirty = PY_SSIZE_T_MAX;
PyErr_Format(PyExc_ValueError,
"%s: found the same %.200s used multiple times",
error_prefix, BPy_BMElem_StringFromHType(htype));
@@ -3945,6 +3948,11 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
return alloc;
err_cleanup:
+ if (do_unique_check && (i_last_dirty != PY_SSIZE_T_MAX)) {
+ for (i = 0; i <= i_last_dirty; i++) {
+ BM_elem_flag_disable(alloc[i], BM_ELEM_INTERNAL_TAG);
+ }
+ }
PyMem_FREE(alloc);
return NULL;
More information about the Bf-blender-cvs
mailing list