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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-01-06 17:50:12 +0300
committerBastien Montagne <bastien@blender.org>2021-01-06 17:59:23 +0300
commita584aef4703aeefe0843f3b8aa2c1e863f825aef (patch)
tree818860977367409c3381021915345044dfacb5cb /source
parent691c021679f6a2038536fcec0bdd7de654c79853 (diff)
Undo: Further tweak/fixes the 'use context' flag of undo types.
Note that this is fairly fragile still, especially in cases like paint cureve undo, which actually does not use context in most cases (and can be called with a NULL context), but do need it in one case. This will need a proper rework at some point.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve_undo.c5
-rw-r--r--source/blender/editors/space_image/image_undo.c6
-rw-r--r--source/blender/editors/space_text/text_undo.c7
3 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.c b/source/blender/editors/sculpt_paint/paint_curve_undo.c
index 82ed4917004..c78af7c38c6 100644
--- a/source/blender/editors/sculpt_paint/paint_curve_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_curve_undo.c
@@ -102,9 +102,12 @@ static bool paintcurve_undosys_step_encode(struct bContext *C,
struct Main *UNUSED(bmain),
UndoStep *us_p)
{
- if (C == NULL || !paint_curve_poll(C)) {
+ /* FIXME Double check this, it should not be needed here at all? undo system is supposed to
+ * ensure that. */
+ if (!paint_curve_poll(C)) {
return false;
}
+
Paint *p = BKE_paint_get_active_from_context(C);
PaintCurve *pc = p ? (p->brush ? p->brush->paint_curve : NULL) : NULL;
if (pc == NULL) {
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index 8c5e2ee2f8a..6cbebd2a959 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -883,9 +883,7 @@ static bool image_undosys_step_encode(struct bContext *C,
}
}
else {
- if (C == NULL) {
- return false;
- }
+ BLI_assert(C != NULL);
/* Happens when switching modes. */
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
BLI_assert(ELEM(paint_mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D));
@@ -998,6 +996,8 @@ void ED_image_undosys_type(UndoType *ut)
ut->step_foreach_ID_ref = image_undosys_foreach_ID_ref;
+ /* NOTE this is actually a confusing case, since it expects a valid context, but only in a
+ * specific case, see `image_undosys_step_encode` code. */
ut->use_context_for_encode = false;
ut->step_size = sizeof(ImageUndoStep);
diff --git a/source/blender/editors/space_text/text_undo.c b/source/blender/editors/space_text/text_undo.c
index c6bcbc06b2f..8bc22833502 100644
--- a/source/blender/editors/space_text/text_undo.c
+++ b/source/blender/editors/space_text/text_undo.c
@@ -183,14 +183,11 @@ 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);
@@ -263,7 +260,7 @@ void ED_text_undosys_type(UndoType *ut)
ut->step_foreach_ID_ref = text_undosys_foreach_ID_ref;
- ut->use_context_for_encode = false;
+ ut->use_context_for_encode = true;
ut->step_size = sizeof(TextUndoStep);
}