diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-31 03:34:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-31 04:07:13 +0300 |
commit | 51bba03b319319d59f739673c3fafb71bc308e0d (patch) | |
tree | 239eaf352608f35d924061002d4fcb8adb4f3749 /source/blender/editors | |
parent | d16e4d077dfe4ac887b51075784170911d3adca5 (diff) |
Undo System: add Main argument to encode/decode
Needed since we don't always have the context,
and avoids adding G_MAIN into undo callbacks.
Diffstat (limited to 'source/blender/editors')
12 files changed, 24 insertions, 26 deletions
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c index 3119c303801..9cd96db7bdf 100644 --- a/source/blender/editors/armature/editarmature_undo.c +++ b/source/blender/editors/armature/editarmature_undo.c @@ -149,7 +149,7 @@ static bool armature_undosys_poll(bContext *C) return editarm_object_from_context(C) != NULL; } -static bool armature_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool armature_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { ArmatureUndoStep *us = (ArmatureUndoStep *)us_p; @@ -173,7 +173,7 @@ static bool armature_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void armature_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void armature_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_EDIT); diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c index 9163272fbf2..282b3722d3b 100644 --- a/source/blender/editors/curve/editcurve_undo.c +++ b/source/blender/editors/curve/editcurve_undo.c @@ -214,7 +214,7 @@ static bool curve_undosys_poll(bContext *C) return (obedit != NULL); } -static bool curve_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool curve_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { CurveUndoStep *us = (CurveUndoStep *)us_p; @@ -237,7 +237,7 @@ static bool curve_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void curve_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void curve_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_EDIT); diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c index 85e361b495f..ab6ef4b4728 100644 --- a/source/blender/editors/curve/editfont_undo.c +++ b/source/blender/editors/curve/editfont_undo.c @@ -339,7 +339,7 @@ static bool font_undosys_poll(bContext *C) return editfont_object_from_context(C) != NULL; } -static bool font_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool font_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { FontUndoStep *us = (FontUndoStep *)us_p; us->obedit_ref.ptr = editfont_object_from_context(C); @@ -349,7 +349,7 @@ static bool font_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void font_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void font_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_EDIT); diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c index 744f353f129..7ca28906861 100644 --- a/source/blender/editors/lattice/editlattice_undo.c +++ b/source/blender/editors/lattice/editlattice_undo.c @@ -151,7 +151,7 @@ static bool lattice_undosys_poll(bContext *C) return editlatt_object_from_context(C) != NULL; } -static bool lattice_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool lattice_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { LatticeUndoStep *us = (LatticeUndoStep *)us_p; @@ -175,7 +175,7 @@ static bool lattice_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void lattice_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void lattice_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_EDIT); diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index 235878fed53..97a411cba54 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -699,7 +699,7 @@ static bool mesh_undosys_poll(bContext *C) return editmesh_object_from_context(C) != NULL; } -static bool mesh_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool mesh_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { MeshUndoStep *us = (MeshUndoStep *)us_p; @@ -723,7 +723,7 @@ static bool mesh_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void mesh_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void mesh_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_EDIT); diff --git a/source/blender/editors/metaball/editmball_undo.c b/source/blender/editors/metaball/editmball_undo.c index ebf056f71db..7616fb63256 100644 --- a/source/blender/editors/metaball/editmball_undo.c +++ b/source/blender/editors/metaball/editmball_undo.c @@ -157,7 +157,7 @@ static bool mball_undosys_poll(bContext *C) return editmball_object_from_context(C) != NULL; } -static bool mball_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool mball_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { MBallUndoStep *us = (MBallUndoStep *)us_p; @@ -181,7 +181,7 @@ static bool mball_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void mball_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void mball_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_EDIT); diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c index 9839248a4cf..ea48d0b70b9 100644 --- a/source/blender/editors/physics/particle_edit_undo.c +++ b/source/blender/editors/physics/particle_edit_undo.c @@ -236,7 +236,7 @@ static bool particle_undosys_poll(struct bContext *C) return (edit != NULL); } -static bool particle_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool particle_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { ParticleUndoStep *us = (ParticleUndoStep *)us_p; ViewLayer *view_layer = CTX_data_view_layer(C); @@ -247,7 +247,7 @@ static bool particle_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void particle_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void particle_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_PARTICLE_EDIT); diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.c b/source/blender/editors/sculpt_paint/paint_curve_undo.c index 59f424a9f31..9e116a5a3aa 100644 --- a/source/blender/editors/sculpt_paint/paint_curve_undo.c +++ b/source/blender/editors/sculpt_paint/paint_curve_undo.c @@ -98,7 +98,7 @@ static void paintcurve_undosys_step_encode_init(struct bContext *C, UndoStep *us UNUSED_VARS(C, us_p); } -static bool paintcurve_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool paintcurve_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { Paint *p = BKE_paint_get_active_from_context(C); PaintCurve *pc = p ? (p->brush ? p->brush->paint_curve : NULL) : NULL; @@ -115,7 +115,7 @@ static bool paintcurve_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void paintcurve_undosys_step_decode(struct bContext *UNUSED(C), UndoStep *us_p, int UNUSED(dir)) +static void paintcurve_undosys_step_decode(struct bContext *UNUSED(C), struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { PaintCurveUndoStep *us = (PaintCurveUndoStep *)us_p; undocurve_to_paintcurve(&us->data, us->pc); diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c index 7a4641008a4..b049e613b86 100644 --- a/source/blender/editors/sculpt_paint/paint_image_undo.c +++ b/source/blender/editors/sculpt_paint/paint_image_undo.c @@ -436,7 +436,7 @@ static void image_undosys_step_encode_init(struct bContext *UNUSED(C), UndoStep BLI_listbase_clear(&us->tiles); } -static bool image_undosys_step_encode(struct bContext *UNUSED(C), UndoStep *us_p) +static bool image_undosys_step_encode(struct bContext *UNUSED(C), struct Main *UNUSED(bmain), UndoStep *us_p) { /* dummy, encoding is done along the way by adding tiles * to the current 'ImageUndoStep' added by encode_init. */ @@ -466,7 +466,7 @@ static bool image_undosys_step_encode(struct bContext *UNUSED(C), UndoStep *us_p return true; } -static void image_undosys_step_decode(struct bContext *UNUSED(C), UndoStep *us_p, int UNUSED(dir)) +static void image_undosys_step_decode(struct bContext *UNUSED(C), struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { ImageUndoStep *us = (ImageUndoStep *)us_p; #if 0 diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 0355f8e933b..8b8493aa415 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -1049,7 +1049,7 @@ static void sculpt_undosys_step_encode_init(struct bContext *UNUSED(C), UndoStep BLI_listbase_clear(&us->data.nodes); } -static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C), UndoStep *us_p) +static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C), struct Main *UNUSED(bmain), UndoStep *us_p) { /* dummy, encoding is done along the way by adding tiles * to the current 'SculptUndoStep' added by encode_init. */ @@ -1063,7 +1063,7 @@ static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C), UndoStep *us_ return true; } -static void sculpt_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void sculpt_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir)) { /* TODO(campbell): undo_system: use low-level API to set mode. */ ED_object_mode_set(C, OB_MODE_SCULPT); diff --git a/source/blender/editors/space_text/text_undo.c b/source/blender/editors/space_text/text_undo.c index f2bbcddcc27..566100f0034 100644 --- a/source/blender/editors/space_text/text_undo.c +++ b/source/blender/editors/space_text/text_undo.c @@ -94,7 +94,7 @@ static void text_undosys_step_encode_init(struct bContext *C, UndoStep *us_p) us->data.pos = -1; } -static bool text_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool text_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p) { TextUndoStep *us = (TextUndoStep *)us_p; @@ -112,7 +112,7 @@ static bool text_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void text_undosys_step_decode(struct bContext *C, UndoStep *us_p, int dir) +static void text_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int dir) { TextUndoStep *us = (TextUndoStep *)us_p; Text *text = us->text_ref.ptr; diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c index 1b0fe9a0c3d..dc1870c2d19 100644 --- a/source/blender/editors/undo/memfile_undo.c +++ b/source/blender/editors/undo/memfile_undo.c @@ -71,12 +71,11 @@ static bool memfile_undosys_poll(bContext *C) return true; } -static bool memfile_undosys_step_encode(struct bContext *C, UndoStep *us_p) +static bool memfile_undosys_step_encode(struct bContext *UNUSED(C), struct Main *bmain, UndoStep *us_p) { MemFileUndoStep *us = (MemFileUndoStep *)us_p; /* Important we only use 'main' from the context (see: BKE_undosys_stack_init_from_main). */ - struct Main *bmain = CTX_data_main(C); UndoStack *ustack = ED_undo_stack_get(); /* can be NULL, use when set. */ @@ -87,9 +86,8 @@ static bool memfile_undosys_step_encode(struct bContext *C, UndoStep *us_p) return true; } -static void memfile_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir)) +static void memfile_undosys_step_decode(struct bContext *C, struct Main *bmain, UndoStep *us_p, int UNUSED(dir)) { - struct Main *bmain = CTX_data_main(C); ED_editors_exit(bmain, false); MemFileUndoStep *us = (MemFileUndoStep *)us_p; |