[Bf-blender-cvs] [d32520932ff] blender-v2.81-release: Fix sculpt + undo curve crash

Campbell Barton noreply at git.blender.org
Wed Nov 13 04:19:57 CET 2019


Commit: d32520932ff58b00b0b67d168c51c050035176fe
Author: Campbell Barton
Date:   Wed Nov 13 13:59:36 2019 +1100
Branches: blender-v2.81-release
https://developer.blender.org/rBd32520932ff58b00b0b67d168c51c050035176fe

Fix sculpt + undo curve crash

PaintCurve data ID data wasn't being remapped.
Error in initial undo refactor.

===================================================================

M	source/blender/blenkernel/BKE_undo_system.h
M	source/blender/editors/sculpt_paint/paint_curve_undo.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list