Merge branch 'master' into blender2.8
[blender.git] / source / blender / windowmanager / intern / wm_files.c
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);
        }
 }