diff options
author | Bastien Montagne <bastien@blender.org> | 2021-01-06 14:25:35 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-01-06 14:28:06 +0300 |
commit | bc3e38ca3a4228b7191e9fec39288c9f37ec53b1 (patch) | |
tree | 6a770e2087fd0a36017db3dc0b13dfae0abc3617 /source/blender/editors/space_text/text_undo.c | |
parent | 4e23f08807bb0ccd361932f335768f645572d6bf (diff) |
Cleanup/refactor: UndoType: Clarify `use_context` variable.
Rename it to mark it is only for `encode` callbacks, fix `encode`
callback of text undo to early fail in case it gets a NULL context, add
an assert to `BKE_undosys_step_push_with_type` that context is not NULL
when undotype requires a valid one.
Note that in practice this should not change anything, currently it
seems that we always get a valid context in
`BKE_undosys_step_push_with_type`?
Diffstat (limited to 'source/blender/editors/space_text/text_undo.c')
-rw-r--r-- | source/blender/editors/space_text/text_undo.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/editors/space_text/text_undo.c b/source/blender/editors/space_text/text_undo.c index 4126f36e44a..c6bcbc06b2f 100644 --- a/source/blender/editors/space_text/text_undo.c +++ b/source/blender/editors/space_text/text_undo.c @@ -183,11 +183,14 @@ static bool text_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { + if (C == NULL) { + return false; + } + TextUndoStep *us = (TextUndoStep *)us_p; Text *text = us->text_ref.ptr; BLI_assert(text == CTX_data_edit_text(C)); - UNUSED_VARS_NDEBUG(C); us->step.data_size += text_undosys_step_encode_to_state(&us->states[1], text); @@ -260,7 +263,7 @@ void ED_text_undosys_type(UndoType *ut) ut->step_foreach_ID_ref = text_undosys_foreach_ID_ref; - ut->use_context = false; + ut->use_context_for_encode = false; ut->step_size = sizeof(TextUndoStep); } |