Fix T38367: operators activated from popups didnt reuse settings
This commit is contained in:
parent
a283b099b1
commit
9a1dcfbf2d
Notes:
blender-bot
2023-02-14 20:10:55 +01:00
Referenced by issue blender/blender-addons#38367, Operators no longer save / restore their last-used properties when invoked.
|
@ -227,6 +227,7 @@ struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *
|
|||
|
||||
int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot);
|
||||
int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context);
|
||||
int WM_operator_call_ex(struct bContext *C, struct wmOperator *op, const bool store);
|
||||
int WM_operator_call (struct bContext *C, struct wmOperator *op);
|
||||
int WM_operator_call_notest(struct bContext *C, struct wmOperator *op);
|
||||
int WM_operator_repeat (struct bContext *C, struct wmOperator *op);
|
||||
|
|
|
@ -649,7 +649,7 @@ static bool wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
|
|||
return wm && (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER);
|
||||
}
|
||||
|
||||
static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
|
||||
static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
|
@ -683,7 +683,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
|
|||
}
|
||||
|
||||
/* if repeat is true, it doesn't register again, nor does it free */
|
||||
static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
|
||||
static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, const bool store)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
int retval = OPERATOR_CANCELLED;
|
||||
|
@ -714,7 +714,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
|
|||
wm_operator_reports(C, op, retval, FALSE);
|
||||
|
||||
if (retval & OPERATOR_FINISHED) {
|
||||
if (repeat) {
|
||||
if (store) {
|
||||
if (wm->op_undo_depth == 0) { /* not called by py script */
|
||||
WM_operator_last_properties_store(op);
|
||||
}
|
||||
|
@ -743,12 +743,21 @@ static int wm_operator_exec_notest(bContext *C, wmOperator *op)
|
|||
return retval;
|
||||
}
|
||||
|
||||
/* for running operators with frozen context (modal handlers, menus)
|
||||
/**
|
||||
* for running operators with frozen context (modal handlers, menus)
|
||||
*
|
||||
* \param store, Store settings for re-use.
|
||||
*
|
||||
* warning: do not use this within an operator to call its self! [#29537] */
|
||||
int WM_operator_call_ex(bContext *C, wmOperator *op,
|
||||
const bool store)
|
||||
{
|
||||
return wm_operator_exec(C, op, false, store);
|
||||
}
|
||||
|
||||
int WM_operator_call(bContext *C, wmOperator *op)
|
||||
{
|
||||
return wm_operator_exec(C, op, 0);
|
||||
return WM_operator_call_ex(C, op, false);
|
||||
}
|
||||
|
||||
/* this is intended to be used when an invoke operator wants to call exec on its self
|
||||
|
@ -762,7 +771,7 @@ int WM_operator_call_notest(bContext *C, wmOperator *op)
|
|||
/* do this operator again, put here so it can share above code */
|
||||
int WM_operator_repeat(bContext *C, wmOperator *op)
|
||||
{
|
||||
return wm_operator_exec(C, op, 1);
|
||||
return wm_operator_exec(C, op, true, true);
|
||||
}
|
||||
/* TRUE if WM_operator_repeat can run
|
||||
* simple check for now but may become more involved.
|
||||
|
|
|
@ -1434,7 +1434,7 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
|
|||
wmOpPopUp *data = arg1;
|
||||
uiBlock *block = arg2;
|
||||
|
||||
WM_operator_call(C, data->op);
|
||||
WM_operator_call_ex(C, data->op, true);
|
||||
|
||||
/* let execute handle freeing it */
|
||||
//data->free_op = FALSE;
|
||||
|
@ -1548,7 +1548,7 @@ static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval)
|
|||
wmOperator *op = data->op;
|
||||
|
||||
if (op && retval > 0)
|
||||
WM_operator_call(C, op);
|
||||
WM_operator_call_ex(C, op, true);
|
||||
|
||||
MEM_freeN(data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue