diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-03-11 16:34:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-03-11 16:40:25 +0300 |
commit | f7616c6eaf8d983e84aeb838d51fe67e4fa98e16 (patch) | |
tree | 2154811d77a2ce3b8a7c8e9165a84477b8534999 /source/blender | |
parent | 93f8c9b8238b4f69c34b605b7e08dfe113f4023d (diff) |
Cleanup: file loading/recover checks
- Don't set G.relbase_valid until the file is loaded.
- Remove unnecessary string pointer comparison.
- Remove unused filename being passed to 'setup_app_data'.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 23 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 5 |
2 files changed, 9 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index a7af0eccb49..c3edd84fd43 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -132,11 +132,9 @@ static void setup_app_userdef(BlendFileData *bfd) * should be avoided or check (mode != LOAD_UNDO). * * \param bfd: Blend file data, freed by this function on exit. - * \param filepath: File path or identifier. */ static void setup_app_data(bContext *C, BlendFileData *bfd, - const char *filepath, const struct BlendFileReadParams *params, ReportList *reports) { @@ -350,16 +348,10 @@ static void setup_app_data(bContext *C, if (is_startup) { bmain->name[0] = '\0'; } - else if (recover && G.relbase_valid) { - /* in case of autosave or quit.blend, use original filename instead - * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */ - filepath = bfd->filename; + else if (recover) { + /* In case of autosave or quit.blend, use original filename instead. */ bmain->recovered = 1; - - /* these are the same at times, should never copy to the same location */ - if (bmain->name != filepath) { - BLI_strncpy(bmain->name, filepath, FILE_MAX); - } + BLI_strncpy(bmain->name, bfd->filename, FILE_MAX); } /* baseflags, groups, make depsgraph, etc */ @@ -413,7 +405,6 @@ static void setup_app_data(bContext *C, static void setup_app_blend_file_data(bContext *C, BlendFileData *bfd, - const char *filepath, const struct BlendFileReadParams *params, ReportList *reports) { @@ -421,7 +412,7 @@ static void setup_app_blend_file_data(bContext *C, setup_app_userdef(bfd); } if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) { - setup_app_data(C, bfd, filepath, params, reports); + setup_app_data(C, bfd, params, reports); } } @@ -460,7 +451,7 @@ bool BKE_blendfile_read_ex(bContext *C, BLO_update_defaults_startup_blend(bfd->main, startup_app_template); } } - setup_app_blend_file_data(C, bfd, filepath, params, reports); + setup_app_blend_file_data(C, bfd, params, reports); BLO_blendfiledata_free(bfd); } else { @@ -493,7 +484,7 @@ bool BKE_blendfile_read_from_memory_ex(bContext *C, BLO_update_defaults_startup_blend(bfd->main, startup_app_template); } } - setup_app_blend_file_data(C, bfd, "<memory2>", params, reports); + setup_app_blend_file_data(C, bfd, params, reports); BLO_blendfiledata_free(bfd); } else { @@ -529,7 +520,7 @@ bool BKE_blendfile_read_from_memfile(bContext *C, BLI_assert(BLI_listbase_is_empty(&bfd->main->workspaces)); BLI_assert(BLI_listbase_is_empty(&bfd->main->screens)); - setup_app_blend_file_data(C, bfd, "<memory1>", params, reports); + setup_app_blend_file_data(C, bfd, params, reports); BLO_blendfiledata_free(bfd); } else { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 13f3afdfc4c..8a8baad0df0 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -729,8 +729,6 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* also exit screens and editors */ wm_window_match_init(C, &wmbase); - /* confusing this global... */ - G.relbase_valid = 1; success = BKE_blendfile_read( C, filepath, @@ -746,9 +744,10 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* BKE_file_read sets new Main into context. */ Main *bmain = CTX_data_main(C); - /* when loading startup.blend's, we can be left with a blank path */ + /* When recovering a session from an unsaved file, this can have a blank path. */ if (BKE_main_blendfile_path(bmain)[0] != '\0') { G.save_over = 1; + G.relbase_valid = 1; } else { G.save_over = 0; |