diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 07:06:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 07:06:19 +0300 |
commit | acd7b81c2d3fa7828d28c1562fad10663d911783 (patch) | |
tree | 5258424d0be22e177fd8019a295740c882e7cfa6 /source/blender/windowmanager | |
parent | ff6e631c86aa934da09db03e9505d5b060007fac (diff) |
bugfix [#25230] Quick extrude Ctrl-LMB : wrong behaviour of 'RotateSource' option.
Problem is is with operator redo which click-extrude exposed.
Check if redo operator can run, otherwise lock the UI and add a label that the operator doesn't support redo.
This is clunky but IMHO better then failing silently and leaving the user confused.
- Merged redo functions into ED_undo_operator_repeat(), code was duplicated in a few places.
- added WM_operator_repeat_check to check if WM_operator_repeat() can run, avoids an undo call when redo work.
Unrelated changes
- GHOST_SystemWin32.cpp set to utf8 encoding.
- cmake_consistency_check.py now checks source files are utf8.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 22 |
3 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 3a47e29f553..9c3e19ef4b7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -221,6 +221,7 @@ int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot); int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context); int WM_operator_call (struct bContext *C, struct wmOperator *op); int WM_operator_repeat (struct bContext *C, struct wmOperator *op); +int WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op); int WM_operator_name_call (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties); int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 579bac52306..08b50ef9d3f 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -514,6 +514,14 @@ int WM_operator_repeat(bContext *C, wmOperator *op) { return wm_operator_exec(C, op, 1); } +/* TRUE if WM_operator_repeat can run + * simple check for now but may become more involved. + * To be sure the operator can run call WM_operator_poll(C, op->type) also, since this call + * checks if WM_operator_repeat() can run at all, not that it WILL run at any time. */ +int WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op) +{ + return op->type->exec != NULL; +} static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, PointerRNA *properties, ReportList *reports) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 9f18f23bdd6..d7c84392a12 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -869,17 +869,6 @@ int WM_operator_winactive(bContext *C) return 1; } -/* op->exec */ -static void redo_cb(bContext *C, void *arg_op, int UNUSED(event)) -{ - wmOperator *lastop= arg_op; - - if(lastop) { - ED_undo_pop_op(C, lastop); - WM_operator_repeat(C, lastop); - } -} - static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) { wmWindowManager *wm= CTX_wm_manager(C); @@ -896,10 +885,10 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); /* if register is not enabled, the operator gets freed on OPERATOR_FINISHED - * ui_apply_but_funcs_after calls redo_cb and crashes */ + * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */ assert(op->type->flag & OPTYPE_REGISTER); - uiBlockSetHandleFunc(block, redo_cb, arg_op); + uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, arg_op); if(!op->properties) { IDPropertyTemplate val = {0}; @@ -910,6 +899,13 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, 20, style); uiItemL(layout, op->type->name, 0); + /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens + * just fails silently */ + if(!WM_operator_repeat_check(C, op)) { + uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator cannot redo"); + uiItemL(layout, "* Redo Unsupported *", 0); // XXX, could give some nicer feedback or not show redo panel at all? + } + if(op->type->ui) { op->layout= layout; op->type->ui((bContext*)C, op); |