Fix error using freed bmain
authorCampbell Barton <ideasman42@gmail.com>
Wed, 6 Jun 2018 07:36:50 +0000 (09:36 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 6 Jun 2018 07:36:50 +0000 (09:36 +0200)
Regression in 481cdb08ed6f3

source/blender/blenkernel/intern/blender_undo.c

index c3306b16041eabe14c0d533f0d9ba4e93d360ef2..df2caba0208b03c570293e40a8f1486d211b0df2 100644 (file)
@@ -82,13 +82,14 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C)
                success = BKE_blendfile_read_from_memfile(C, &mfu->memfile, NULL, 0);
        }
 
-       /* restore */
-       BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name)); /* restore */
+       /* Restore, bmain has been re-allocated. */
+       bmain = CTX_data_main(C);
+       BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name));
        G.fileflags = fileflags;
 
        if (success) {
                /* important not to update time here, else non keyed tranforms are lost */
-               DAG_on_visible_update(G.main, false);
+               DAG_on_visible_update(bmain, false);
        }
 
        return success;