diff options
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_operators.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 37b1c9386e5..4a611d78d58 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1553,32 +1553,39 @@ typedef struct BMOpError { struct BMOpError *next, *prev; BMOperator *op; const char *msg; + eBMOpErrorLevel level; } BMOpError; void BMO_error_clear(BMesh *bm) { - while (BMO_error_pop(bm, NULL, NULL)) { + while (BMO_error_pop(bm, NULL, NULL, NULL)) { /* pass */ } } -void BMO_error_raise(BMesh *bm, BMOperator *owner, const char *msg) +void BMO_error_raise(BMesh *bm, BMOperator *owner, eBMOpErrorLevel level, const char *msg) { BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error"); err->msg = msg; err->op = owner; + err->level = level; BLI_addhead(&bm->errorstack, err); } -bool BMO_error_occurred(BMesh *bm) +bool BMO_error_occurred_at_level(BMesh *bm, eBMOpErrorLevel level) { - return (BLI_listbase_is_empty(&bm->errorstack) == false); + for (const BMOpError *err = bm->errorstack.first; err; err = err->next) { + if (err->level == level) { + return true; + } + } + return false; } /* returns error code or 0 if no error */ -bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op) +bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op, eBMOpErrorLevel *r_level) { BMOpError *err = bm->errorstack.first; if (err == NULL) { @@ -1591,13 +1598,36 @@ bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op) if (r_op) { *r_op = err->op; } + if (r_level) { + *r_level = err->level; + } return true; } -bool BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op) +bool BMO_error_get_at_level(BMesh *bm, + eBMOpErrorLevel level, + const char **r_msg, + BMOperator **r_op) +{ + for (BMOpError *err = bm->errorstack.first; err; err = err->next) { + if (err->level >= level) { + if (r_msg) { + *r_msg = err->msg; + } + if (r_op) { + *r_op = err->op; + } + return true; + } + } + + return false; +} + +bool BMO_error_pop(BMesh *bm, const char **r_msg, BMOperator **r_op, eBMOpErrorLevel *r_level) { - bool result = BMO_error_get(bm, msg, op); + bool result = BMO_error_get(bm, r_msg, r_op, r_level); if (result) { BMOpError *err = bm->errorstack.first; |