diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_blendfile.h | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender_undo.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 37 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 14 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 9 | ||||
-rw-r--r-- | source/blender/blenloader/intern/undofile.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 21 | ||||
-rw-r--r-- | source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 |
10 files changed, 74 insertions, 34 deletions
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index 9ff164f60be..74fdde93d9a 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -34,6 +34,7 @@ struct Main; struct MemFile; struct ReportList; struct UserDef; +struct BlendFileReadParams; enum { BKE_BLENDFILE_READ_FAIL = 0, /* no load */ @@ -43,13 +44,16 @@ enum { int BKE_blendfile_read( struct bContext *C, const char *filepath, - struct ReportList *reports, int skip_flag); + const struct BlendFileReadParams *params, + struct ReportList *reports); bool BKE_blendfile_read_from_memory( - struct bContext *C, const void *filebuf, int filelength, - struct ReportList *reports, int skip_flag, bool update_defaults); + struct bContext *C, const void *filebuf, int filelength, bool update_defaults, + const struct BlendFileReadParams *params, + struct ReportList *reports); bool BKE_blendfile_read_from_memfile( struct bContext *C, struct MemFile *memfile, - struct ReportList *reports, int skip_flag); + const struct BlendFileReadParams *params, + struct ReportList *reports); void BKE_blendfile_read_make_empty(struct bContext *C); struct UserDef *BKE_blendfile_userdef_read( diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index df2caba0208..441687c1c01 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -55,6 +55,7 @@ #include "BKE_main.h" #include "BLO_undofile.h" +#include "BLO_readfile.h" #include "BLO_writefile.h" /* -------------------------------------------------------------------- */ @@ -79,7 +80,10 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) success = (BKE_blendfile_read(C, mfu->filename, NULL, 0) != BKE_BLENDFILE_READ_FAIL); } else { - success = BKE_blendfile_read_from_memfile(C, &mfu->memfile, NULL, 0); + success = BKE_blendfile_read_from_memfile( + C, &mfu->memfile, + &(const struct BlendFileReadParams){0}, + NULL); } /* Restore, bmain has been re-allocated. */ diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index c92648da67c..c6cb8a412fe 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -111,11 +111,12 @@ static bool wm_scene_is_visible(wmWindowManager *wm, Scene *scene) */ static void setup_app_data( bContext *C, BlendFileData *bfd, - const char *filepath, ReportList *reports) + const char *filepath, + const bool is_startup, + ReportList *reports) { Main *bmain = G_MAIN; Scene *curscene = NULL; - const bool is_startup = (bfd->filename[0] == '\0'); const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; enum { LOAD_UI = 1, @@ -296,7 +297,7 @@ static void setup_app_data( bmain->recovered = 0; /* startup.blend or recovered startup */ - if (bfd->filename[0] == 0) { + if (is_startup) { bmain->name[0] = '\0'; } else if (recover && G.relbase_valid) { @@ -351,7 +352,8 @@ static int handle_subversion_warning(Main *main, ReportList *reports) int BKE_blendfile_read( bContext *C, const char *filepath, - ReportList *reports, int skip_flags) + const struct BlendFileReadParams *params, + ReportList *reports) { BlendFileData *bfd; int retval = BKE_BLENDFILE_READ_OK; @@ -361,7 +363,7 @@ int BKE_blendfile_read( printf("Read blend: %s\n", filepath); } - bfd = BLO_read_from_file(filepath, reports, skip_flags); + bfd = BLO_read_from_file(filepath, params->skip_flags, reports); if (bfd) { if (bfd->user) { retval = BKE_BLENDFILE_READ_OK_USERPREFS; @@ -374,7 +376,7 @@ int BKE_blendfile_read( retval = BKE_BLENDFILE_READ_FAIL; } else { - setup_app_data(C, bfd, filepath, reports); + setup_app_data(C, bfd, filepath, params->is_startup, reports); } } else @@ -384,16 +386,17 @@ int BKE_blendfile_read( } bool BKE_blendfile_read_from_memory( - bContext *C, const void *filebuf, int filelength, - ReportList *reports, int skip_flags, bool update_defaults) + bContext *C, const void *filebuf, int filelength, bool update_defaults, + const struct BlendFileReadParams *params, + ReportList *reports) { BlendFileData *bfd; - bfd = BLO_read_from_memory(filebuf, filelength, reports, skip_flags); + bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports); if (bfd) { if (update_defaults) BLO_update_defaults_startup_blend(bfd->main); - setup_app_data(C, bfd, "<memory2>", reports); + setup_app_data(C, bfd, "<memory2>", params->is_startup, reports); } else { BKE_reports_prepend(reports, "Loading failed: "); @@ -405,12 +408,13 @@ bool BKE_blendfile_read_from_memory( /* memfile is the undo buffer */ bool BKE_blendfile_read_from_memfile( bContext *C, struct MemFile *memfile, - ReportList *reports, int skip_flags) + const struct BlendFileReadParams *params, + ReportList *reports) { Main *bmain = CTX_data_main(C); BlendFileData *bfd; - bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, reports, skip_flags); + bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, params->skip_flags, reports); if (bfd) { /* remove the unused screens and wm */ while (bfd->main->wm.first) @@ -418,7 +422,7 @@ bool BKE_blendfile_read_from_memfile( while (bfd->main->screen.first) BKE_libblock_free(bfd->main, bfd->main->screen.first); - setup_app_data(C, bfd, "<memory1>", reports); + setup_app_data(C, bfd, "<memory1>", params->is_startup, reports); } else { BKE_reports_prepend(reports, "Loading failed: "); @@ -459,7 +463,7 @@ UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports) BlendFileData *bfd; UserDef *userdef = NULL; - bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF); + bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, reports); if (bfd) { if (bfd->user) { userdef = bfd->user; @@ -479,7 +483,10 @@ UserDef *BKE_blendfile_userdef_read_from_memory( BlendFileData *bfd; UserDef *userdef = NULL; - bfd = BLO_read_from_memory(filebuf, filelength, reports, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF); + bfd = BLO_read_from_memory( + filebuf, filelength, + BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, + reports); if (bfd) { if (bfd->user) { userdef = bfd->user; diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 11f34732cfc..5a1c479f450 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -48,6 +48,7 @@ struct View3D; struct bContext; struct BHead; struct FileData; +struct BlendFileReadParams; typedef struct BlendHandle BlendHandle; @@ -71,6 +72,10 @@ typedef struct BlendFileData { eBlenFileType type; } BlendFileData; +struct BlendFileReadParams { + uint skip_flags : 2; /* eBLOReadSkip */ + uint is_startup : 1; +}; /* skip reading some data-block types (may want to skip screen data too). */ typedef enum eBLOReadSkip { @@ -83,13 +88,16 @@ typedef enum eBLOReadSkip { BlendFileData *BLO_read_from_file( const char *filepath, - struct ReportList *reports, eBLOReadSkip skip_flag); + eBLOReadSkip skip_flags, + struct ReportList *reports); BlendFileData *BLO_read_from_memory( const void *mem, int memsize, - struct ReportList *reports, eBLOReadSkip skip_flag); + eBLOReadSkip skip_flags, + struct ReportList *reports); BlendFileData *BLO_read_from_memfile( struct Main *oldmain, const char *filename, struct MemFile *memfile, - struct ReportList *reports, eBLOReadSkip skip_flag); + eBLOReadSkip skip_flags, + struct ReportList *reports); void BLO_blendfiledata_free(BlendFileData *bfd); diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 7488d62bb3c..b2bcf745eac 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -319,7 +319,8 @@ void BLO_blendhandle_close(BlendHandle *bh) */ BlendFileData *BLO_read_from_file( const char *filepath, - ReportList *reports, eBLOReadSkip skip_flags) + eBLOReadSkip skip_flags, + ReportList *reports) { BlendFileData *bfd = NULL; FileData *fd; @@ -346,7 +347,8 @@ BlendFileData *BLO_read_from_file( */ BlendFileData *BLO_read_from_memory( const void *mem, int memsize, - ReportList *reports, eBLOReadSkip skip_flags) + eBLOReadSkip skip_flags, + ReportList *reports) { BlendFileData *bfd = NULL; FileData *fd; @@ -370,7 +372,8 @@ BlendFileData *BLO_read_from_memory( */ BlendFileData *BLO_read_from_memfile( Main *oldmain, const char *filename, MemFile *memfile, - ReportList *reports, eBLOReadSkip skip_flags) + eBLOReadSkip skip_flags, + ReportList *reports) { BlendFileData *bfd = NULL; FileData *fd; diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index 614a3be559b..37cd69b72f2 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -130,7 +130,7 @@ void memfile_chunk_add( struct Main *BLO_memfile_main_get(struct MemFile *memfile, struct Main *oldmain, struct Scene **r_scene) { struct Main *bmain_undo = NULL; - BlendFileData *bfd = BLO_read_from_memfile(oldmain, BKE_main_blendfile_path(oldmain), memfile, NULL, BLO_READ_SKIP_NONE); + BlendFileData *bfd = BLO_read_from_memfile(oldmain, BKE_main_blendfile_path(oldmain), memfile, BLO_READ_SKIP_NONE, NULL); if (bfd) { bmain_undo = bfd->main; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index e1042f17229..a8069b01026 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -196,7 +196,7 @@ static Main *load_main_from_memory(const void *blend, int blend_size) BlendFileData *bfd; G.fileflags |= G_FILE_NO_UI; - bfd = BLO_read_from_memory(blend, blend_size, NULL, BLO_READ_SKIP_NONE); + bfd = BLO_read_from_memory(blend, blend_size, BLO_READ_SKIP_NONE, NULL); if (bfd) { bmain = bfd->main; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ef951010ba5..acb954a4b05 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -569,7 +569,10 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* confusing this global... */ G.relbase_valid = 1; - retval = BKE_blendfile_read(C, filepath, reports, 0); + retval = BKE_blendfile_read( + C, filepath, + &(const struct BlendFileReadParams){0}, + reports); /* BKE_file_read sets new Main into context. */ Main *bmain = CTX_data_main(C); @@ -804,7 +807,13 @@ int wm_homefile_read( if (!use_factory_settings || (filepath_startup[0] != '\0')) { if (BLI_access(filepath_startup, R_OK) == 0) { - success = (BKE_blendfile_read(C, filepath_startup, NULL, skip_flags) != BKE_BLENDFILE_READ_FAIL); + success = BKE_blendfile_read( + C, filepath_startup, + &(const struct BlendFileReadParams){ + .is_startup = true, + .skip_flags = skip_flags, + }, + NULL) != BKE_BLENDFILE_READ_FAIL; } if (BLI_listbase_is_empty(&U.themes)) { if (G.debug & G_DEBUG) @@ -820,8 +829,12 @@ int wm_homefile_read( if (success == false) { success = BKE_blendfile_read_from_memory( - C, datatoc_startup_blend, datatoc_startup_blend_size, - NULL, skip_flags, true); + C, datatoc_startup_blend, datatoc_startup_blend_size, true, + &(const struct BlendFileReadParams){ + .is_startup = true, + .skip_flags = skip_flags, + }, + NULL); if (success) { if (use_userdef) { if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) { diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 22616458b54..84cbf4bf85b 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -110,7 +110,8 @@ static BlendFileData *load_game_data(const char *filename) BlendFileData *bfd; BKE_reports_init(&reports, RPT_STORE); - bfd= BLO_read_from_file(filename, &reports, BLO_READ_SKIP_USERDEF); + bfd= BLO_read_from_file(filename, BLO_READ_SKIP_USERDEF, &reports); + if (!bfd) { printf("Loading %s failed: ", filename); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 42b603f8980..46b477a6da5 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -355,7 +355,7 @@ static BlendFileData *load_game_data(const char *progname, char *filename = NULL BLI_strncpy(bfd->main->name, progname, sizeof(bfd->main->name)); } } else { - bfd= BLO_read_from_file(progname, &reports, BLO_READ_SKIP_NONE); + bfd= BLO_read_from_file(progname, BLO_READ_SKIP_NONE, &reports); } if (!bfd && filename) { |