WM: store modal operator last-properties
Avoids modal operators needing to explicitly store them.
This commit is contained in:
parent
946a4fe85a
commit
83b60dac57
Notes:
blender-bot
2023-02-14 10:32:59 +01:00
Referenced by commit 56ea42efa1
, Radial control: Skip operator properties from being saved
Referenced by issue #53441, 'Inset' function does not start at zero
Referenced by issue #53145, Bevel Problem
|
@ -744,12 +744,16 @@ static bool wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
|
|||
return wm && (wm->op_undo_depth == 0) && (ot->flag & (OPTYPE_REGISTER | OPTYPE_UNDO));
|
||||
}
|
||||
|
||||
static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat)
|
||||
static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat, const bool store)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
op->customdata = NULL;
|
||||
|
||||
if (store) {
|
||||
WM_operator_last_properties_store(op);
|
||||
}
|
||||
|
||||
/* we don't want to do undo pushes for operators that are being
|
||||
* called from operators that already do an undo push. usually
|
||||
* this will happen for python operators that call C operators */
|
||||
|
@ -812,12 +816,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
|
|||
wm_operator_reports(C, op, retval, false);
|
||||
|
||||
if (retval & OPERATOR_FINISHED) {
|
||||
if (store) {
|
||||
if (wm->op_undo_depth == 0) { /* not called by py script */
|
||||
WM_operator_last_properties_store(op);
|
||||
}
|
||||
}
|
||||
wm_operator_finished(C, op, repeat);
|
||||
wm_operator_finished(C, op, repeat, store && wm->op_undo_depth == 0);
|
||||
}
|
||||
else if (repeat == 0) {
|
||||
/* warning: modal from exec is bad practice, but avoid crashing. */
|
||||
|
@ -1173,10 +1172,8 @@ static int wm_operator_invoke(
|
|||
/* do nothing, wm_operator_exec() has been called somewhere */
|
||||
}
|
||||
else if (retval & OPERATOR_FINISHED) {
|
||||
if (!is_nested_call) { /* not called by py script */
|
||||
WM_operator_last_properties_store(op);
|
||||
}
|
||||
wm_operator_finished(C, op, 0);
|
||||
const bool store = !is_nested_call;
|
||||
wm_operator_finished(C, op, false, store);
|
||||
}
|
||||
else if (retval & OPERATOR_RUNNING_MODAL) {
|
||||
/* take ownership of reports (in case python provided own) */
|
||||
|
@ -1752,7 +1749,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
|
|||
|
||||
/* important to run 'wm_operator_finished' before NULLing the context members */
|
||||
if (retval & OPERATOR_FINISHED) {
|
||||
wm_operator_finished(C, op, 0);
|
||||
wm_operator_finished(C, op, false, true);
|
||||
handler->op = NULL;
|
||||
}
|
||||
else if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
|
||||
|
|
|
@ -2491,9 +2491,6 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
}
|
||||
case GESTURE_MODAL_CANCEL:
|
||||
case GESTURE_MODAL_CONFIRM:
|
||||
/* Normally we wouldn't store last-properties on cancel,
|
||||
* this is an exception since the circle tool is modal. */
|
||||
WM_operator_last_properties_store(op);
|
||||
wm_gesture_end(C, op);
|
||||
return OPERATOR_FINISHED; /* use finish or we don't get an undo */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue