diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_undo_system.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/undo_system.c | 27 |
2 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h index 2863642a3e0..33eefcf6085 100644 --- a/source/blender/blenkernel/BKE_undo_system.h +++ b/source/blender/blenkernel/BKE_undo_system.h @@ -29,6 +29,7 @@ struct UndoStep; struct bContext; /* ID's */ +struct Main; struct Mesh; struct Object; struct Scene; @@ -115,8 +116,8 @@ typedef struct UndoType { */ void (*step_encode_init)(struct bContext *C, UndoStep *us); - bool (*step_encode)(struct bContext *C, UndoStep *us); - void (*step_decode)(struct bContext *C, UndoStep *us, int dir); + bool (*step_encode)(struct bContext *C, struct Main *bmain, UndoStep *us); + void (*step_decode)(struct bContext *C, struct Main *bmain, UndoStep *us, int dir); /** * \note When freeing all steps, diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index d16f0569a57..ab375da0925 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -146,16 +146,15 @@ static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref) } } -static bool undosys_step_encode(bContext *C, UndoStack *ustack, UndoStep *us) +static bool undosys_step_encode(bContext *C, Main *bmain, UndoStack *ustack, UndoStep *us) { CLOG_INFO(&LOG, 2, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name); UNDO_NESTED_CHECK_BEGIN; - bool ok = us->type->step_encode(C, us); + bool ok = us->type->step_encode(C, bmain, us); UNDO_NESTED_CHECK_END; if (ok) { if (us->type->step_foreach_ID_ref != NULL) { /* Don't use from context yet because sometimes context is fake and not all members are filled in. */ - Main *bmain = G.main; us->type->step_foreach_ID_ref(us, undosys_id_ref_store, bmain); } #ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER @@ -170,7 +169,7 @@ static bool undosys_step_encode(bContext *C, UndoStack *ustack, UndoStep *us) return ok; } -static void undosys_step_decode(bContext *C, UndoStack *ustack, UndoStep *us, int dir) +static void undosys_step_decode(bContext *C, Main *bmain, UndoStack *ustack, UndoStep *us, int dir) { CLOG_INFO(&LOG, 2, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name); @@ -185,7 +184,7 @@ static void undosys_step_decode(bContext *C, UndoStack *ustack, UndoStep *us, in else { /* Load the previous memfile state so any ID's referenced in this * undo step will be correctly resolved, see: T56163. */ - undosys_step_decode(C, ustack, us_iter, dir); + undosys_step_decode(C, bmain, ustack, us_iter, dir); } break; } @@ -193,12 +192,11 @@ static void undosys_step_decode(bContext *C, UndoStack *ustack, UndoStep *us, in } #endif /* Don't use from context yet because sometimes context is fake and not all members are filled in. */ - Main *bmain = G.main; us->type->step_foreach_ID_ref(us, undosys_id_ref_resolve, bmain); } UNDO_NESTED_CHECK_BEGIN; - us->type->step_decode(C, us, dir); + us->type->step_decode(C, bmain, us, dir); UNDO_NESTED_CHECK_END; #ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER @@ -487,6 +485,7 @@ UndoStep *BKE_undosys_step_push_init(UndoStack *ustack, bContext *C, const char */ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char *name, const UndoType *ut) { + Main *bmain = G.main; UNDO_NESTED_ASSERT(false); undosys_stack_validate(ustack, false); bool is_not_empty = ustack->step_active != NULL; @@ -510,7 +509,6 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char #ifdef WITH_GLOBAL_UNDO_ENSURE_UPDATED if (ut->step_foreach_ID_ref != NULL) { - Main *bmain = G.main; if (bmain->is_memfile_undo_written == false) { const char *name_internal = "MemFile Internal (pre)"; /* Don't let 'step_init' cause issues when adding memfile undo step. */ @@ -541,7 +539,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char us->type = ut; /* initialized, not added yet. */ - if (!undosys_step_encode(C, ustack, us)) { + if (!undosys_step_encode(C, bmain, ustack, us)) { MEM_freeN(us); undosys_stack_validate(ustack, true); return false; @@ -552,7 +550,6 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char } if (use_memfile_step) { - Main *bmain = G.main; const char *name_internal = "MemFile Internal (post)"; const bool ok = undosys_stack_push_main(ustack, name_internal, bmain); if (ok) { @@ -647,6 +644,7 @@ bool BKE_undosys_step_undo_with_data_ex( bool use_skip) { UNDO_NESTED_ASSERT(false); + Main *bmain = G.main; if (us) { undosys_stack_validate(ustack, true); } @@ -664,14 +662,14 @@ bool BKE_undosys_step_undo_with_data_ex( UndoStep *us_iter = ustack->step_active; while (us_iter != us) { if (us_iter->type->mode == BKE_UNDOTYPE_MODE_ACCUMULATE) { - undosys_step_decode(C, ustack, us_iter, -1); + undosys_step_decode(C, bmain, ustack, us_iter, -1); } us_iter = us_iter->prev; } } if (us->type->mode != BKE_UNDOTYPE_MODE_ACCUMULATE) { - undosys_step_decode(C, ustack, us, -1); + undosys_step_decode(C, bmain, ustack, us, -1); } ustack->step_active = us_prev; undosys_stack_validate(ustack, true); @@ -706,6 +704,7 @@ bool BKE_undosys_step_redo_with_data_ex( UndoStack *ustack, bContext *C, UndoStep *us, bool use_skip) { + Main *bmain = G.main; UNDO_NESTED_ASSERT(false); UndoStep *us_next = us ? us->next : NULL; /* Unlike undo accumulate, we always use the next. */ @@ -719,14 +718,14 @@ bool BKE_undosys_step_redo_with_data_ex( UndoStep *us_iter = ustack->step_active->next; while (us_iter != us) { if (us_iter->type->mode == BKE_UNDOTYPE_MODE_ACCUMULATE) { - undosys_step_decode(C, ustack, us_iter, 1); + undosys_step_decode(C, bmain, ustack, us_iter, 1); } us_iter = us_iter->next; } } /* Unlike undo, always redo accumulation state. */ - undosys_step_decode(C, ustack, us, 1); + undosys_step_decode(C, bmain, ustack, us, 1); ustack->step_active = us_next; if (use_skip) { if (ustack->step_active && ustack->step_active->skip) { |