diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f1e9f30dac5..d6568ea9c15 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1068,17 +1068,20 @@ int wm_userpref_write_exec(bContext *C, wmOperator *op) void wm_autosave_location(char *filepath) { - char pidstr[32]; + const int pid = abs(getpid()); char path[1024]; #ifdef WIN32 const char *savedir; #endif - BLI_snprintf(pidstr, sizeof(pidstr), "%d", abs(getpid())); - if (G.main) - BLI_snprintf(path, sizeof(path), "%s-%s", pidstr, BLI_path_basename(G.main->name)); - else - BLI_snprintf(path, sizeof(path), "%s.blend", pidstr); + if (G.main && G.relbase_valid) { + const char *basename = BLI_path_basename(G.main->name); + int len = strlen(basename) - 6; + BLI_snprintf(path, sizeof(path), "%.*s-%d.blend", len, basename, pid); + } + else { + BLI_snprintf(path, sizeof(path), "%d.blend", pid); + } #ifdef WIN32 /* XXX Need to investigate how to handle default location of '/tmp/' |