Commit: 3296d5619db40adb8e2cb9137393981b45cd9fee Author: Bastien Montagne Date: Thu Jan 30 15:29:20 2020 +0100 Branches: undo-experiments-swap-reread-datablocks https://developer.blender.org/rB3296d5619db40adb8e2cb9137393981b45cd9fee
undoexp: tweak `setup_app_data()` to better handle undo case. The way we detected undo case there was somewhat weak, now we have a stronger way to do it from `BlendFileReadParams`. =================================================================== M source/blender/blenkernel/intern/blendfile.c =================================================================== diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 8c654b001ff..cd685ec67a6 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -134,26 +134,29 @@ static void setup_app_userdef(BlendFileData *bfd) static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath, - const bool is_startup, + const struct BlendFileReadParams *params, ReportList *reports) { Main *bmain = G_MAIN; Scene *curscene = NULL; const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; + const bool is_startup = params->is_startup; enum { LOAD_UI = 1, LOAD_UI_OFF, LOAD_UNDO, } mode; - /* may happen with library files - UNDO file should never have NULL cursccene... */ - if (ELEM(NULL, bfd->curscreen, bfd->curscene)) { + if (params->undo_direction != 0) { + BLI_assert(bfd->curscene != NULL); + mode = LOAD_UNDO; + } + /* may happen with library files - UNDO file should never have NULL curscene (but may have a + * NULL curscreen)... */ + else if (ELEM(NULL, bfd->curscreen, bfd->curscene)) { BKE_report(reports, RPT_WARNING, "Library file, loading empty scene"); mode = LOAD_UI_OFF; } - else if (BLI_listbase_is_empty(&bfd->main->screens)) { - mode = LOAD_UNDO; - } else if (G.fileflags & G_FILE_NO_UI) { mode = LOAD_UI_OFF; } @@ -386,7 +389,7 @@ static void setup_app_blend_file_data(bContext *C, setup_app_userdef(bfd); } if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) { - setup_app_data(C, bfd, filepath, params->is_startup, reports); + setup_app_data(C, bfd, filepath, params, reports); } } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs