Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-12-16 03:38:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-12-16 03:41:46 +0300
commit5de109cc2d220ca3bd731216b9cd521269ad663e (patch)
treea97d9cff164edd723aa66c81b78281b5cf99ef24 /source/blender/blenloader
parent4b12f521e38fedf09485e0436e339031f363130a (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')
-rw-r--r--source/blender/blenloader/BLO_writefile.h5
-rw-r--r--source/blender/blenloader/intern/writefile.c11
2 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h
index 9bc3714ff38..57b1199a870 100644
--- a/source/blender/blenloader/BLO_writefile.h
+++ b/source/blender/blenloader/BLO_writefile.h
@@ -60,6 +60,11 @@ struct BlendFileWriteParams {
uint use_save_versions : 1;
/** On write, restore paths after editing them (see #BLO_WRITE_PATH_REMAP_RELATIVE). */
uint use_save_as_copy : 1;
+ /**
+ * Saving from the UI writes into the #Main.filepath, so a check for the `filepath`
+ * not having been set is needed.
+ */
+ uint use_save_first_time : 1;
uint use_userdef : 1;
const struct BlendThumbnail *thumb;
};
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;