diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-12-16 03:38:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-12-16 03:41:46 +0300 |
commit | 5de109cc2d220ca3bd731216b9cd521269ad663e (patch) | |
tree | a97d9cff164edd723aa66c81b78281b5cf99ef24 /source/blender/blenkernel/intern/pointcache.c | |
parent | 4b12f521e38fedf09485e0436e339031f363130a (diff) |
Remove G.relbase_valid
In almost all cases there is no difference between `G.relbase_valid`
and checking `G.main->filepath` isn't an empty string.
In many places a non-empty string is already being used instead of
`G.relbase_valid`.
The only situation where this was needed was when saving from
`wm_file_write` where they temporarily became out of sync.
This has been replaced by adding a new member to `BlendFileWriteParams`
to account for saving an unsaved file for the first time.
Reviewed By: brecht
Ref D13564
Diffstat (limited to 'source/blender/blenkernel/intern/pointcache.c')
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 094181afca9..df76f003498 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1322,10 +1322,11 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext) static int ptcache_path(PTCacheID *pid, char *filename) { + const char *blendfile_path = BKE_main_blendfile_path_from_global(); Library *lib = (pid->owner_id) ? pid->owner_id->lib : NULL; const char *blendfilename = (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH) == 0) ? lib->filepath_abs : - BKE_main_blendfile_path_from_global(); + blendfile_path; size_t i; if (pid->cache->flag & PTCACHE_EXTERNAL) { @@ -1337,7 +1338,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) return BLI_path_slash_ensure(filename); /* new strlen() */ } - if (G.relbase_valid || lib) { + if ((blendfile_path[0] != '\0') || lib) { char file[MAX_PTCACHE_PATH]; /* we don't want the dir, only the file */ BLI_split_file_part(blendfilename, file, sizeof(file)); @@ -1422,8 +1423,11 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p filename[0] = '\0'; newname = filename; - if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0) { - return 0; /* save blend file before using disk pointcache */ + if ((pid->cache->flag & PTCACHE_EXTERNAL) == 0) { + const char *blendfile_path = BKE_main_blendfile_path_from_global(); + if (blendfile_path[0] == '\0') { + return 0; /* save blend file before using disk pointcache */ + } } /* start with temp dir */ @@ -1469,8 +1473,11 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) return NULL; } #endif - if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0) { - return NULL; /* save blend file before using disk pointcache */ + if ((pid->cache->flag & PTCACHE_EXTERNAL) == 0) { + const char *blendfile_path = BKE_main_blendfile_path_from_global(); + if (blendfile_path[0] == '\0') { + return NULL; /* save blend file before using disk pointcache */ + } } ptcache_filename(pid, filename, cfra, 1, 1); @@ -3444,8 +3451,9 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { PointCache *cache = pid->cache; int last_exact = cache->last_exact; + const char *blendfile_path = BKE_main_blendfile_path_from_global(); - if (!G.relbase_valid) { + if (blendfile_path[0] == '\0') { cache->flag &= ~PTCACHE_DISK_CACHE; if (G.debug & G_DEBUG) { printf("File must be saved before using disk cache!\n"); |