Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/undo/ed_undo.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| static CLG_LogRef LOG = {"ed.undo"}; | static CLG_LogRef LOG = {"ed.undo"}; | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Generic Undo System Access | /** \name Generic Undo System Access | ||||
| * | * | ||||
| * Non-operator undo editor functions. | * Non-operator undo editor functions. | ||||
| * \{ */ | * \{ */ | ||||
| void ED_undo_push(bContext *C, const char *str) | void ed_undo_push_impl(bContext *C, const char *str, UndoType *ut) | ||||
| { | { | ||||
| CLOG_INFO(&LOG, 1, "name='%s'", str); | CLOG_INFO(&LOG, 1, "name='%s'", str); | ||||
| const int steps = U.undosteps; | const int steps = U.undosteps; | ||||
| if (steps <= 0) { | if (steps <= 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| /* Only apply limit if this is the last undo step. */ | /* Only apply limit if this is the last undo step. */ | ||||
| if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == NULL)) { | if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == NULL)) { | ||||
| BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, steps - 1, 0); | BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, steps - 1, 0); | ||||
| } | } | ||||
| if (ut) { | |||||
| BKE_undosys_step_push_with_type(wm->undo_stack, C, str, ut); | |||||
| } | |||||
| else { | |||||
| BKE_undosys_step_push(wm->undo_stack, C, str); | BKE_undosys_step_push(wm->undo_stack, C, str); | ||||
| } | |||||
| if (U.undomemory != 0) { | if (U.undomemory != 0) { | ||||
| const size_t memory_limit = (size_t)U.undomemory * 1024 * 1024; | const size_t memory_limit = (size_t)U.undomemory * 1024 * 1024; | ||||
| BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, 0, memory_limit); | BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, 0, memory_limit); | ||||
| } | } | ||||
| WM_file_tag_modified(); | WM_file_tag_modified(); | ||||
| } | } | ||||
| void ED_undo_push(bContext *C, const char *str) | |||||
| { | |||||
| ed_undo_push_impl(C, str, NULL); | |||||
| } | |||||
| void ED_undo_push_main(bContext *C, const char *str) | |||||
| { | |||||
| ed_undo_push_impl(C, str, BKE_UNDOSYS_TYPE_MEMFILE); | |||||
| } | |||||
| /** | /** | ||||
| * \note Also check #undo_history_exec in bottom if you change notifiers. | * \note Also check #undo_history_exec in bottom if you change notifiers. | ||||
| */ | */ | ||||
| static int ed_undo_step_impl( | static int ed_undo_step_impl( | ||||
| bContext *C, int step, const char *undoname, int undo_index, ReportList *reports) | bContext *C, int step, const char *undoname, int undo_index, ReportList *reports) | ||||
| { | { | ||||
| /* Mutually exclusives, ensure correct input. */ | /* Mutually exclusives, ensure correct input. */ | ||||
| BLI_assert(((undoname || undo_index != -1) && !step) || | BLI_assert(((undoname || undo_index != -1) && !step) || | ||||
| ▲ Show 20 Lines • Show All 623 Lines • Show Last 20 Lines | |||||