Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Tue, 15 May 2018 17:53:34 +0000 (19:53 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 15 May 2018 17:53:34 +0000 (19:53 +0200)
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 62710240109773136719cb1616b8a365e20fb8ea..f5e4c354a02b58820cd1e5908cc9e1235763a848 100644 (file)
@@ -252,6 +252,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 efb3d0e746187d2fc8dafb06048d1a589945f4f5..721ea158d514d8cac9fd6b30a593556d8930ee62 100644 (file)
@@ -525,16 +525,6 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
                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 */
-
-               /* Ensure tools are registered. */
-               WM_toolsystem_init(C);
-       }
-
        if (!G.background) {
                if (wm->undo_stack == NULL) {
                        wm->undo_stack = BKE_undosys_stack_create();
@@ -543,6 +533,17 @@ 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 */
+
+               /* Ensure tools are registered. */
+               WM_toolsystem_init(C);
        }
 }