diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-19 16:17:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-31 21:40:37 +0300 |
commit | 651b8fb14eb6ee5cbfa98bffe80a966a0753b14e (patch) | |
tree | 2281978509d82a25fb5fbf586f34335e3606442d /source/blender/windowmanager/intern/wm_init_exit.c | |
parent | 91d0825b5556150c017dad767f7971bb6a731aec (diff) |
Undo: unified undo system w/ linear history
- Use a single undo history for all operations.
- UndoType's are registered and poll the context to check if they
should be used when performing an undo push.
- Mode switching is used to ensure the state is correct before
undo data is restored.
- Some undo types accumulate changes (image & text editing)
others store the state multiple times (with de-duplication).
This is supported by checking UndoStack.mode `ACCUMULATE` / `STORE`.
- Each undo step stores ID datablocks they use with utilities to help
manage restoring correct ID's.
Needed since global undo is now mixed with other modes undo.
- Currently performs each undo step when going up/down history
Previously this wasn't done, making history fail in some cases.
This can be optimized to skip some combinations of undo steps.
grease-pencil is an exception which has not been updated
since it integrates undo into the draw-session.
See D3113
Diffstat (limited to 'source/blender/windowmanager/intern/wm_init_exit.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 2743216ee07..b9ac05e0c57 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -55,6 +55,7 @@ #include "BLI_utildefines.h" #include "BLO_writefile.h" +#include "BLO_undofile.h" #include "BKE_blender.h" #include "BKE_blender_undo.h" @@ -149,11 +150,6 @@ static void wm_free_reports(bContext *C) BKE_reports_clear(reports); } -static void wm_undo_kill_callback(bContext *C) -{ - WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C)); -} - bool wm_start_with_console = false; /* used in creator.c */ /* only called once, for startup */ @@ -172,7 +168,7 @@ void WM_init(bContext *C, int argc, const char **argv) WM_menutype_init(); WM_uilisttype_init(); - BKE_undo_callback_wm_kill_jobs_set(wm_undo_kill_callback); + ED_undosys_type_init(); BKE_library_callback_free_window_manager_set(wm_close_and_free); /* library.c */ BKE_library_callback_free_notifier_reference_set(WM_main_remove_notifier_reference); /* library.c */ @@ -478,7 +474,8 @@ void WM_exit_ext(bContext *C, const bool do_python) wmWindow *win; if (!G.background) { - if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_is_valid(NULL)) { + struct MemFile *undo_memfile = wm->undo_stack ? ED_undosys_stack_memfile_get_active(wm->undo_stack) : NULL; + if ((U.uiflag2 & USER_KEEP_SESSION) || (undo_memfile != NULL)) { /* save the undo state as quit.blend */ char filename[FILE_MAX]; bool has_edited; @@ -489,7 +486,7 @@ void WM_exit_ext(bContext *C, const bool do_python) has_edited = ED_editors_flush_edits(C, false); if ((has_edited && BLO_write_file(CTX_data_main(C), filename, fileflags, NULL, NULL)) || - BKE_undo_save_file(filename)) + (undo_memfile && BLO_memfile_write_file(undo_memfile, filename))) { printf("Saved session recovery to '%s'\n", filename); } @@ -512,11 +509,13 @@ void WM_exit_ext(bContext *C, const bool do_python) wm_dropbox_free(); WM_menutype_free(); WM_uilisttype_free(); - + /* all non-screen and non-space stuff editors did, like editmode */ if (C) ED_editors_exit(C); + ED_undosys_type_free(); + // XXX // BIF_GlobalReebFree(); // BIF_freeRetarget(); @@ -594,8 +593,6 @@ void WM_exit_ext(bContext *C, const bool do_python) GPU_exit(); } - BKE_undo_reset(); - ED_file_exit(); /* for fsmenu */ UI_exit(); |