diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-08 02:15:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-08 02:15:11 +0300 |
commit | 3d16a268ee688da25f72a1adb08fdaab454c344d (patch) | |
tree | c6310e141431fe18828c12e1d8aca79545fa9cd7 /source/blender/editors/undo | |
parent | e1edb516994f88e1c1c03ec9f68d0bb0815ba6be (diff) |
Undo System: basic support in background mode
Some developers were using undo for their scripts, this allows for undo
pushes in background mode, however - as with 2.7x, undo isn't
initialized at startup in background mode.
See replies to T60934
Diffstat (limited to 'source/blender/editors/undo')
-rw-r--r-- | source/blender/editors/undo/ed_undo.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index ffe752e11b1..c1ab4edb8e8 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -323,6 +323,15 @@ static int ed_undo_exec(bContext *C, wmOperator *op) static int ed_undo_push_exec(bContext *C, wmOperator *op) { + if (G.background) { + /* Exception for background mode, see: T60934. + * Note: since the undo stack isn't initialized on startup, background mode behavior + * won't match regular usage, this is just for scripts to do explicit undo pushes. */ + wmWindowManager *wm = CTX_wm_manager(C); + if (wm->undo_stack == NULL) { + wm->undo_stack = BKE_undosys_stack_create(); + } + } char str[BKE_UNDO_STR_MAX]; RNA_string_get(op->ptr, "message", str); ED_undo_push(C, str); @@ -357,7 +366,7 @@ static bool ed_undo_is_init_poll(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); if (wm->undo_stack == NULL) { - CTX_wm_operator_poll_msg_set(C, "Undo disabled in background mode or at startup"); + CTX_wm_operator_poll_msg_set(C, "Undo disabled at startup"); return false; } return true; @@ -399,7 +408,8 @@ void ED_OT_undo_push(wmOperatorType *ot) /* api callbacks */ ot->exec = ed_undo_push_exec; - ot->poll = ed_undo_is_init_poll; + /* Unlike others undo operators this initializes undo stack. */ + ot->poll = ED_operator_screenactive; ot->flag = OPTYPE_INTERNAL; |