Fix T55032: Redo w/ file saved in edit-mode failed
authorCampbell Barton <ideasman42@gmail.com>
Tue, 15 May 2018 17:30:59 +0000 (19:30 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 15 May 2018 17:37:06 +0000 (19:37 +0200)
It's important edit-mode has a step stored for redo to work,
file load now ensures this in a generic way.

source/blender/blenkernel/BKE_undo_system.h
source/blender/blenkernel/intern/undo_system.c
source/blender/windowmanager/intern/wm_files.c

index 53ea8ddefe84cc39a2f3f71df8920989442bfb9a..05093deec702aabba97f4bf071cd66353c0610da 100644 (file)
@@ -137,6 +137,7 @@ void            BKE_undosys_stack_destroy(UndoStack *ustack);
 void            BKE_undosys_stack_clear(UndoStack *ustack);
 bool            BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name);
 void            BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
+void            BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);
 UndoStep       *BKE_undosys_stack_active_with_type(UndoStack *ustack, const UndoType *ut);
 UndoStep       *BKE_undosys_stack_init_or_active_with_type(UndoStack *ustack, const UndoType *ut);
 void            BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit);
index 5a0081bff1647b0710d0d0e7d87252f966cedb19..7eaf42591f0619054dff093a50d383f6558bd6bd 100644 (file)
@@ -251,6 +251,15 @@ void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain)
        undosys_stack_push_main(ustack, "original", bmain);
 }
 
+/* called after 'BKE_undosys_stack_init_from_main' */
+void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
+{
+       const UndoType *ut = BKE_undosys_type_from_context(C);
+       if ((ut != NULL) && (ut != BKE_UNDOSYS_TYPE_MEMFILE) && (ut->mode == BKE_UNDOTYPE_MODE_STORE)) {
+               BKE_undosys_step_push_with_type(ustack, C, "original mode", ut);
+       }
+}
+
 /* name optional */
 bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name)
 {
index da5ebd7abcd956b69ea7afb44f58f6e80fee3ff4..1f85d764d45da2f65db8f959a4433775034167bb 100644 (file)
@@ -516,14 +516,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
        if (addons_loaded) {
                wm_file_read_report(C);
        }
-
-       if (!G.background) {
-               /* in background mode this makes it hard to load
-                * a blend file and do anything since the screen
-                * won't be set to a valid value again */
-               CTX_wm_window_set(C, NULL); /* exits queues */
-       }
-
+       
        if (!G.background) {
                if (wm->undo_stack == NULL) {
                        wm->undo_stack = BKE_undosys_stack_create();
@@ -532,6 +525,14 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
                        BKE_undosys_stack_clear(wm->undo_stack);
                }
                BKE_undosys_stack_init_from_main(wm->undo_stack, CTX_data_main(C));
+               BKE_undosys_stack_init_from_context(wm->undo_stack, C);
+       }
+
+       if (!G.background) {
+               /* in background mode this makes it hard to load
+                * a blend file and do anything since the screen
+                * won't be set to a valid value again */
+               CTX_wm_window_set(C, NULL); /* exits queues */
        }
 }