fix for the update issue reported in [#32452]

When blending shape key, opening the popup didnt execute anything - making it so pressing a button would update the result even if the value didnt change.
This commit is contained in:
Campbell Barton 2012-11-14 06:13:42 +00:00
parent 697d29cbed
commit 4cd129bb50
3 changed files with 28 additions and 5 deletions

@ -2438,7 +2438,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
totshape = CustomData_number_of_layers(&em->bm->vdata, CD_SHAPEKEY);
if (totshape == 0 || shape < 0 || shape >= totshape)
return OPERATOR_CANCELLED;
/* get shape key - needed for finding reference shape (for add mode only) */
if (key) {
kb = BLI_findlink(&key->block, shape);
@ -2517,7 +2517,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
/* api callbacks */
ot->exec = edbm_blend_from_shape_exec;
ot->invoke = WM_operator_props_popup;
ot->invoke = WM_operator_props_popup_call;
ot->poll = ED_operator_editmesh;
/* flags */

@ -181,6 +181,7 @@ int WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const char imt
/* poll callback, context checks */
int WM_operator_winactive (struct bContext *C);
/* invoke callback, exec + redo popup */
int WM_operator_props_popup_call(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_operator_props_dialog_popup (struct bContext *C, struct wmOperator *op, int width, int height);
int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op);

@ -1201,8 +1201,11 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height)
return OPERATOR_RUNNING_MODAL;
}
/* operator menu needs undo, for redo callback */
int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
/**
* For use by #WM_operator_props_popup_call, #WM_operator_props_popup only.
*
* \note operator menu needs undo flag enabled , for redo callback */
static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_call)
{
if ((op->type->flag & OPTYPE_REGISTER) == 0) {
@ -1210,15 +1213,34 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
"Operator '%s' does not have register enabled, incorrect invoke function", op->type->idname);
return OPERATOR_CANCELLED;
}
ED_undo_push_op(C, op);
wm_operator_register(C, op);
uiPupBlock(C, wm_block_create_redo, op);
if (do_call) {
WM_operator_repeat(C, op);
}
return OPERATOR_RUNNING_MODAL;
}
/* Same as WM_operator_props_popup but call the operator first,
* This way - the button values corraspond to the result of the operator.
* Without this, first access to a button will make the result jump,
* see [#32452] */
int WM_operator_props_popup_call(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
return wm_operator_props_popup_ex(C, op, TRUE);
}
int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
return wm_operator_props_popup_ex(C, op, FALSE);
}
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height)
{
wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup");