From bda9a2dc8bbdbcf92094092bfdcc732c1eafee34 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2011 13:06:49 +0000 Subject: [PATCH] ensure dirty flags / index arrays are in a valid state before & after executing a BMO in debug mode. --- source/blender/bmesh/bmesh.h | 2 ++ source/blender/bmesh/bmesh_error.h | 3 +++ source/blender/bmesh/intern/bmesh_operators.c | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index 6e0c3cef4d6..056f99c83d3 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -332,6 +332,8 @@ void BM_Clear_Mesh(BMesh *bm); void BM_ElemIndex_Ensure(BMesh *bm, const char hflag); +void BM_ElemIndex_Validate(BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b); + /*start/stop edit*/ void bmesh_begin_edit(struct BMesh *bm, int flag); void bmesh_end_edit(struct BMesh *bm, int flag); diff --git a/source/blender/bmesh/bmesh_error.h b/source/blender/bmesh/bmesh_error.h index 3482402b45b..a93963f3d95 100644 --- a/source/blender/bmesh/bmesh_error.h +++ b/source/blender/bmesh/bmesh_error.h @@ -26,6 +26,9 @@ void BMO_ClearStack(BMesh *bm); int BMO_CatchOpError(BMesh *bm, BMOperator *catchop, int errorcode, char **msg); #endif +#define BM_ELEM_INDEX_VALIDATE(_bm, _msg_a, _msg_b) \ + BM_ElemIndex_Validate(_bm, __FILE__ ":" STRINGIFY(__LINE__), __func__, _msg_a, _msg_b) + /*------ error code defines -------*/ /*error messages*/ diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index b78e71a51b1..fd5b3d5cecf 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1289,6 +1289,10 @@ int BMO_CallOpf(BMesh *bm, const char *fmt, ...) va_list list; BMOperator op; +#ifdef DEBUG + BM_ELEM_INDEX_VALIDATE(bm, "pre bmo", fmt); +#endif + va_start(list, fmt); if (!BMO_VInitOpf(bm, &op, fmt, list)) { printf("%s: failed, format is:\n \"%s\"\n", __func__, fmt); @@ -1299,6 +1303,10 @@ int BMO_CallOpf(BMesh *bm, const char *fmt, ...) BMO_Exec_Op(bm, &op); BMO_Finish_Op(bm, &op); +#ifdef DEBUG + BM_ELEM_INDEX_VALIDATE(bm, "post bmo", fmt); +#endif + va_end(list); return 1; }