diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-03-15 19:54:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-03-15 20:02:24 +0300 |
commit | c832354e330c575a5c450cf0febebb7cc058df87 (patch) | |
tree | ab8fa9d05934abf70b06db0839fbea425fd83264 /source/blender/blenloader | |
parent | c44cdd5905d3112a46a984b8d49710fb1c1546a0 (diff) |
Load user-preferences before startup file
Internal change needed for template support.
Loading the user preferences first so it's possible
for preferences to control startup behavior.
In general it's useful to load preferences before data-files,
so we know security settings for eg.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 16 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 15 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 7 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.h | 2 |
4 files changed, 33 insertions, 7 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index c85cf128643..e07d567ce61 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -71,11 +71,21 @@ typedef struct BlendFileData { BlenFileType type; } BlendFileData; -BlendFileData *BLO_read_from_file(const char *filepath, struct ReportList *reports); -BlendFileData *BLO_read_from_memory(const void *mem, int memsize, struct ReportList *reports); + +/* skip reading some data-block types (may want to skip screen data too). */ +typedef enum eBLOReadSkip { + BLO_READ_SKIP_USERDEF = (1 << 0), +} eBLOReadSkip; + +BlendFileData *BLO_read_from_file( + const char *filepath, + struct ReportList *reports, eBLOReadSkip skip_flag); +BlendFileData *BLO_read_from_memory( + const void *mem, int memsize, + struct ReportList *reports, eBLOReadSkip skip_flag); BlendFileData *BLO_read_from_memfile( struct Main *oldmain, const char *filename, struct MemFile *memfile, - struct ReportList *reports); + struct ReportList *reports, eBLOReadSkip skip_flag); void BLO_blendfiledata_free(BlendFileData *bfd); diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index be893177b3b..73109413271 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -317,7 +317,9 @@ void BLO_blendhandle_close(BlendHandle *bh) * \param reports If the return value is NULL, errors indicating the cause of the failure. * \return The data of the file. */ -BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports) +BlendFileData *BLO_read_from_file( + const char *filepath, + ReportList *reports, eBLOReadSkip skip_flags) { BlendFileData *bfd = NULL; FileData *fd; @@ -325,6 +327,7 @@ BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports) fd = blo_openblenderfile(filepath, reports); if (fd) { fd->reports = reports; + fd->skip_flags = skip_flags; bfd = blo_read_file_internal(fd, filepath); blo_freefiledata(fd); } @@ -341,7 +344,9 @@ BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports) * \param reports If the return value is NULL, errors indicating the cause of the failure. * \return The data of the file. */ -BlendFileData *BLO_read_from_memory(const void *mem, int memsize, ReportList *reports) +BlendFileData *BLO_read_from_memory( + const void *mem, int memsize, + ReportList *reports, eBLOReadSkip skip_flags) { BlendFileData *bfd = NULL; FileData *fd; @@ -349,6 +354,7 @@ BlendFileData *BLO_read_from_memory(const void *mem, int memsize, ReportList *re fd = blo_openblendermemory(mem, memsize, reports); if (fd) { fd->reports = reports; + fd->skip_flags = skip_flags; bfd = blo_read_file_internal(fd, ""); blo_freefiledata(fd); } @@ -362,7 +368,9 @@ BlendFileData *BLO_read_from_memory(const void *mem, int memsize, ReportList *re * \param oldmain old main, from which we will keep libraries and other datablocks that should not have changed. * \param filename current file, only for retrieving library data. */ -BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFile *memfile, ReportList *reports) +BlendFileData *BLO_read_from_memfile( + Main *oldmain, const char *filename, MemFile *memfile, + ReportList *reports, eBLOReadSkip skip_flags) { BlendFileData *bfd = NULL; FileData *fd; @@ -371,6 +379,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil fd = blo_openblendermemfile(memfile, reports); if (fd) { fd->reports = reports; + fd->skip_flags = skip_flags; BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase)); /* clear ob->proxy_from pointers in old main */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 638f877c841..91c96aef8e8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8597,7 +8597,12 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) bhead = read_global(bfd, fd, bhead); break; case USER: - bhead = read_userdef(bfd, fd, bhead); + if (fd->skip_flags & BLO_READ_SKIP_USERDEF) { + bhead = blo_nextbhead(fd, bhead); + } + else { + bhead = read_userdef(bfd, fd, bhead); + } break; case ENDB: bhead = NULL; diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index d97bef13a78..62ce15a640e 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -81,6 +81,8 @@ typedef struct FileData { int id_name_offs; /* used to retrieve ID names from (bhead+1) */ int globalf, fileflags; /* for do_versions patching */ + eBLOReadSkip skip_flags; /* skip some data-blocks */ + struct OldNewMap *datamap; struct OldNewMap *globmap; struct OldNewMap *libmap; |