diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-07 08:13:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-07 08:13:03 +0400 |
commit | 8740b6cd88b9dada05a2e49b23e2ced6c184044a (patch) | |
tree | 6883a6d9e573f32c50f28c9ca3110479ccc7a613 /source/blender/blenloader | |
parent | cdce3e09493c8bf4395de163342760409aad1407 (diff) |
fix [#33108] Running save_as_mainfile breaks relative texture paths
save-as with path remapping left the paths relate to the file written.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 8521b43e437..ac5366c26a3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2890,7 +2890,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.winpos= G.winpos; /* prevent to save this, is not good convention, and feature with concerns... */ - fg.fileflags= (fileflags & ~(G_FILE_NO_UI|G_FILE_RELATIVE_REMAP|G_FILE_MESH_COMPAT)); + fg.fileflags= (fileflags & ~G_FILE_FLAGS_RUNTIME); fg.globalf= G.f; BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename)); @@ -3039,6 +3039,10 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL char tempname[FILE_MAX+1]; int file, err, write_user_block; + /* path backup/restore */ + void *path_list_backup = NULL; + const int path_list_flag = (BLI_BPATH_TRAVERSE_SKIP_LIBRARY | BLI_BPATH_TRAVERSE_SKIP_MULTIFILE); + /* open temporary file, so we preserve the original in case we crash */ BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath); @@ -3048,6 +3052,11 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL return 0; } + /* check if we need to backup and restore paths */ + if (UNLIKELY((write_flags & G_FILE_RELATIVE_REMAP) && (G_FILE_SAVE_COPY & write_flags))) { + path_list_backup = BLI_bpath_list_backup(mainvar, path_list_flag); + } + /* remapping of relative paths to new file location */ if (write_flags & G_FILE_RELATIVE_REMAP) { char dir1[FILE_MAX]; @@ -3083,6 +3092,11 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL err= write_file_handle(mainvar, file, NULL, NULL, write_user_block, write_flags, thumb); close(file); + if (UNLIKELY(path_list_backup)) { + BLI_bpath_list_restore(mainvar, path_list_flag, path_list_backup); + BLI_bpath_list_free(path_list_backup); + } + if (err) { BKE_report(reports, RPT_ERROR, strerror(errno)); remove(tempname); |