diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-03-14 18:37:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-03-14 19:57:01 +0300 |
commit | 1208792adb30f1a2a4833b0503ce240f5f349501 (patch) | |
tree | 616ed5a2e92ed88d868973118cdc66561da2a3d8 /source/blender | |
parent | 582f9ddeb7aa4d2139cef4d0b0f53be32adcf852 (diff) |
WM: store operators with undo flag
This is needed so we can tell if operators are executed repeatedly.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 18 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 23 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 4 |
3 files changed, 32 insertions, 13 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index a7a0a240259..1c17f8c12ff 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2904,9 +2904,20 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot) static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) { wmOperator *lastop = CTX_wm_manager(C)->operators.last; - - if (lastop) + + /* Seek last registered operator */ + while (lastop) { + if (lastop->type->flag & OPTYPE_REGISTER) { + break; + } + else { + lastop = lastop->prev; + } + } + + if (lastop) { WM_operator_repeat(C, lastop); + } return OPERATOR_CANCELLED; } @@ -2941,8 +2952,9 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU layout = UI_popup_menu_layout(pup); for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) - if (WM_operator_repeat_check(C, lastop)) + if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) { uiItemIntO(layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i); + } UI_popup_menu_end(C, pup); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index b76a1f1d422..8fe38a97dac 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -149,18 +149,23 @@ static void wm_reports_free(wmWindowManager *wm) void wm_operator_register(bContext *C, wmOperator *op) { wmWindowManager *wm = CTX_wm_manager(C); - int tot; + int tot = 0; BLI_addtail(&wm->operators, op); - tot = BLI_listbase_count(&wm->operators); - - while (tot > MAX_OP_REGISTERED) { - wmOperator *opt = wm->operators.first; - BLI_remlink(&wm->operators, opt); - WM_operator_free(opt); - tot--; + + /* only count registered operators */ + while (op) { + wmOperator *op_prev = op->prev; + if (op->type->flag & OPTYPE_REGISTER) { + tot += 1; + } + if (tot > MAX_OP_REGISTERED) { + BLI_remlink(&wm->operators, op); + WM_operator_free(op); + } + op = op_prev; } - + /* so the console is redrawn */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL); WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index eba132062c9..282091bb814 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -715,7 +715,9 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca */ static bool wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot) { - return wm && (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER); + /* Check undo flag here since undo operators are also added to the list, + * to support checking if the same operator is run twice. */ + 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) |