diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-11-13 05:59:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-11-13 06:04:18 +0300 |
commit | d32520932ff58b00b0b67d168c51c050035176fe (patch) | |
tree | 660d32be831cab95c9fb831e220bb11949ab2d4c | |
parent | 4782e941c816f8965e243e43d26a87150ee6afd5 (diff) |
Fix sculpt + undo curve crash
PaintCurve data ID data wasn't being remapped.
Error in initial undo refactor.
-rw-r--r-- | source/blender/blenkernel/BKE_undo_system.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_curve_undo.c | 18 |
2 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h index 6d8e04336ac..bc10d422a61 100644 --- a/source/blender/blenkernel/BKE_undo_system.h +++ b/source/blender/blenkernel/BKE_undo_system.h @@ -49,6 +49,7 @@ UNDO_REF_ID_TYPE(Object); UNDO_REF_ID_TYPE(Scene); UNDO_REF_ID_TYPE(Text); UNDO_REF_ID_TYPE(Image); +UNDO_REF_ID_TYPE(PaintCurve); typedef struct UndoStack { ListBase steps; diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.c b/source/blender/editors/sculpt_paint/paint_curve_undo.c index c14ccd27804..5797eb68dd3 100644 --- a/source/blender/editors/sculpt_paint/paint_curve_undo.c +++ b/source/blender/editors/sculpt_paint/paint_curve_undo.c @@ -77,7 +77,9 @@ static void undocurve_free_data(UndoCurve *uc) typedef struct PaintCurveUndoStep { UndoStep step; - PaintCurve *pc; + + UndoRefID_PaintCurve pc_ref; + UndoCurve data; } PaintCurveUndoStep; @@ -112,7 +114,7 @@ static bool paintcurve_undosys_step_encode(struct bContext *C, PaintCurveUndoStep *us = (PaintCurveUndoStep *)us_p; BLI_assert(us->step.data_size == 0); - us->pc = pc; + us->pc_ref.ptr = pc; undocurve_from_paintcurve(&us->data, pc); return true; @@ -125,7 +127,7 @@ static void paintcurve_undosys_step_decode(struct bContext *UNUSED(C), bool UNUSED(is_final)) { PaintCurveUndoStep *us = (PaintCurveUndoStep *)us_p; - undocurve_to_paintcurve(&us->data, us->pc); + undocurve_to_paintcurve(&us->data, us->pc_ref.ptr); } static void paintcurve_undosys_step_free(UndoStep *us_p) @@ -134,6 +136,14 @@ static void paintcurve_undosys_step_free(UndoStep *us_p) undocurve_free_data(&us->data); } +static void paintcurve_undosys_foreach_ID_ref(UndoStep *us_p, + UndoTypeForEachIDRefFn foreach_ID_ref_fn, + void *user_data) +{ + PaintCurveUndoStep *us = (PaintCurveUndoStep *)us_p; + foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->pc_ref)); +} + /* Export for ED_undo_sys. */ void ED_paintcurve_undosys_type(UndoType *ut) { @@ -145,6 +155,8 @@ void ED_paintcurve_undosys_type(UndoType *ut) ut->step_decode = paintcurve_undosys_step_decode; ut->step_free = paintcurve_undosys_step_free; + ut->step_foreach_ID_ref = paintcurve_undosys_foreach_ID_ref; + ut->use_context = false; ut->step_size = sizeof(PaintCurveUndoStep); |