Fix file-selector operators performing an undo push on failure

Operators are only expected to perform an undo push when finished.
This commit is contained in:
Campbell Barton
2025-02-28 11:45:11 +11:00
parent f9df73b875
commit 322abbd311

View File

@@ -2917,12 +2917,14 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C,
}
/* XXX check this carefully, `CTX_wm_manager(C) == wm` is a bit hackish. */
if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) {
if (handler->op->type->flag & OPTYPE_UNDO) {
ED_undo_push_op(C, handler->op);
}
else if (handler->op->type->flag & OPTYPE_UNDO_GROUPED) {
ED_undo_grouped_push_op(C, handler->op);
if (retval & OPERATOR_FINISHED) {
if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) {
if (handler->op->type->flag & OPTYPE_UNDO) {
ED_undo_push_op(C, handler->op);
}
else if (handler->op->type->flag & OPTYPE_UNDO_GROUPED) {
ED_undo_grouped_push_op(C, handler->op);
}
}
}