Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-01 06:05:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-01 06:11:26 +0300
commit1b7c361fbb320744e6b7cc0c03b5f850e8fbfd9e (patch)
tree920cb6cd06e8128c329026feaffa047040b35fa0 /source/blender/editors/undo
parent552b2287db86ed6e77565672fbccff1d553f823f (diff)
WM: disable undo operators in background mode & at startup
Show an error instead of crashing, see: T60934
Diffstat (limited to 'source/blender/editors/undo')
-rw-r--r--source/blender/editors/undo/ed_undo.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 6f39be0f7c6..d427086af66 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -351,11 +351,31 @@ static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
return ret;
}
+/* Disable in background mode, we could support if it's useful, T60934. */
+
+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");
+ return false;
+ }
+ return true;
+}
+
+static bool ed_undo_is_init_and_screenactive_poll(bContext *C)
+{
+ if (ed_undo_is_init_poll(C) == false) {
+ return false;
+ }
+ return ED_operator_screenactive(C);
+}
+
static bool ed_undo_redo_poll(bContext *C)
{
wmOperator *last_op = WM_operator_last_redo(C);
- return last_op && ED_operator_screenactive(C) &&
- WM_operator_check_ui_enabled(C, last_op->type->name);
+ return (last_op && ed_undo_is_init_and_screenactive_poll(C) &&
+ WM_operator_check_ui_enabled(C, last_op->type->name));
}
void ED_OT_undo(wmOperatorType *ot)
@@ -367,7 +387,7 @@ void ED_OT_undo(wmOperatorType *ot)
/* api callbacks */
ot->exec = ed_undo_exec;
- ot->poll = ED_operator_screenactive;
+ ot->poll = ed_undo_is_init_and_screenactive_poll;
}
void ED_OT_undo_push(wmOperatorType *ot)
@@ -379,6 +399,7 @@ void ED_OT_undo_push(wmOperatorType *ot)
/* api callbacks */
ot->exec = ed_undo_push_exec;
+ ot->poll = ed_undo_is_init_poll;
ot->flag = OPTYPE_INTERNAL;
@@ -394,7 +415,7 @@ void ED_OT_redo(wmOperatorType *ot)
/* api callbacks */
ot->exec = ed_redo_exec;
- ot->poll = ED_operator_screenactive;
+ ot->poll = ed_undo_is_init_and_screenactive_poll;
}
void ED_OT_undo_redo(wmOperatorType *ot)
@@ -605,7 +626,7 @@ void ED_OT_undo_history(wmOperatorType *ot)
/* api callbacks */
ot->invoke = undo_history_invoke;
ot->exec = undo_history_exec;
- ot->poll = ED_operator_screenactive;
+ ot->poll = ed_undo_is_init_and_screenactive_poll;
RNA_def_int(ot->srna, "item", 0, 0, INT_MAX, "Item", "", 0, INT_MAX);