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/blenloader/intern/writefile.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/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 45258a50961..3709ff4db5f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1326,6 +1326,8 @@ bool BLO_write_file(Main *mainvar, const bool use_save_as_copy = params->use_save_as_copy; const bool use_userdef = params->use_userdef; const BlendThumbnail *thumb = params->thumb; + const bool relbase_valid = (mainvar->filepath[0] != '\0') && + (params->use_save_first_time == false); /* path backup/restore */ void *path_list_backup = NULL; @@ -1353,9 +1355,8 @@ bool BLO_write_file(Main *mainvar, if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) { if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) { - /* Make all relative as none of the existing paths can be relative in an unsaved document. - */ - if (G.relbase_valid == false) { + /* Make all relative as none of the existing paths can be relative in an unsaved document. */ + if (relbase_valid == false) { remap_mode = BLO_WRITE_PATH_REMAP_RELATIVE_ALL; } } @@ -1371,13 +1372,13 @@ bool BLO_write_file(Main *mainvar, /* Only for relative, not relative-all, as this means making existing paths relative. */ if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) { - if (G.relbase_valid && (BLI_path_cmp(dir_dst, dir_src) == 0)) { + if (relbase_valid && (BLI_path_cmp(dir_dst, dir_src) == 0)) { /* Saved to same path. Nothing to do. */ remap_mode = BLO_WRITE_PATH_REMAP_NONE; } } else if (remap_mode == BLO_WRITE_PATH_REMAP_ABSOLUTE) { - if (G.relbase_valid == false) { + if (relbase_valid == false) { /* Unsaved, all paths are absolute.Even if the user manages to set a relative path, * there is no base-path that can be used to make it absolute. */ remap_mode = BLO_WRITE_PATH_REMAP_NONE; |