From 5cce6894d2a7704dcd445d471764af4c6baa65aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Dec 2021 21:32:14 +1100 Subject: Cleanup: consistent naming for the blender file name --- source/blender/blenkernel/intern/library.c | 4 ++-- source/blender/blenkernel/intern/sound.c | 12 ++++-------- source/blender/editors/space_file/filelist.c | 4 ++-- source/blender/windowmanager/intern/wm_files.c | 26 +++++++++++++------------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index d7282b14734..c97b003d241 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -127,7 +127,7 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath) */ /* Never make paths relative to parent lib - reading code (blenloader) always set *all* * `lib->filepath` relative to current main, not to their parent for indirectly linked ones. */ - const char *basepath = BKE_main_blendfile_path(bmain); - BLI_path_abs(lib->filepath_abs, basepath); + const char *blendfile_path = BKE_main_blendfile_path(bmain); + BLI_path_abs(lib->filepath_abs, blendfile_path); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 3e99896054a..b27231e6a17 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -271,14 +271,11 @@ BLI_INLINE void sound_verify_evaluated_id(const ID *id) bSound *BKE_sound_new_file(Main *bmain, const char *filepath) { bSound *sound; - const char *path; + const char *blendfile_path = BKE_main_blendfile_path(bmain); char str[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - - path = BKE_main_blendfile_path(bmain); - - BLI_path_abs(str, path); + BLI_path_abs(str, blendfile_path); sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0); BLI_strncpy(sound->filepath, filepath, FILE_MAX); @@ -1249,15 +1246,14 @@ bool BKE_sound_stream_info_get(struct Main *main, int stream, SoundStreamInfo *sound_info) { - const char *path; + const char *blendfile_path = BKE_main_blendfile_path(main); char str[FILE_MAX]; AUD_Sound *sound; AUD_StreamInfo *stream_infos; int stream_count; BLI_strncpy(str, filepath, sizeof(str)); - path = BKE_main_blendfile_path(main); - BLI_path_abs(str, path); + BLI_path_abs(str, blendfile_path); sound = AUD_Sound_file(str); if (!sound) { diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 533c1bc32c7..e4ea832fe2f 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -3859,8 +3859,8 @@ static void filelist_readjob_main_assets_add_items(FileListReadJob *job_params, */ static bool filelist_contains_main(const FileList *filelist, const Main *bmain) { - const char *main_path = BKE_main_blendfile_path(bmain); - return main_path[0] && BLI_path_contains(filelist->filelist.root, main_path); + const char *blendfile_path = BKE_main_blendfile_path(bmain); + return blendfile_path[0] && BLI_path_contains(filelist->filelist.root, blendfile_path); } static void filelist_readjob_asset_library(FileListReadJob *job_params, diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 8f05e6ccaba..eb1be7ef484 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1491,18 +1491,18 @@ static void wm_history_file_write(void) static void wm_history_file_update(void) { RecentFile *recent; - const char *blendfile_name = BKE_main_blendfile_path_from_global(); + const char *blendfile_path = BKE_main_blendfile_path_from_global(); - /* no write history for recovered startup files */ - if (blendfile_name[0] == '\0') { + /* No write history for recovered startup files. */ + if (blendfile_path[0] == '\0') { return; } recent = G.recent_files.first; /* refresh recent-files.txt of recent opened files, when current file was changed */ - if (!(recent) || (BLI_path_cmp(recent->filepath, blendfile_name) != 0)) { + if (!(recent) || (BLI_path_cmp(recent->filepath, blendfile_path) != 0)) { - recent = wm_file_history_find(blendfile_name); + recent = wm_file_history_find(blendfile_path); if (recent) { BLI_remlink(&G.recent_files, recent); } @@ -1513,7 +1513,7 @@ static void wm_history_file_update(void) recent_next = recent->next; wm_history_file_free(recent); } - recent = wm_history_file_new(blendfile_name); + recent = wm_history_file_new(blendfile_path); } /* add current file to the beginning of list */ @@ -1523,7 +1523,7 @@ static void wm_history_file_update(void) wm_history_file_write(); /* also update most recent files on System */ - GHOST_addToSystemRecentFiles(blendfile_name); + GHOST_addToSystemRecentFiles(blendfile_path); } } @@ -2607,7 +2607,7 @@ static int wm_open_mainfile__select_file_path(bContext *C, wmOperator *op) set_next_operator_state(op, OPEN_MAINFILE_STATE_OPEN); Main *bmain = CTX_data_main(C); - const char *openname = BKE_main_blendfile_path(bmain); + const char *blendfile_path = BKE_main_blendfile_path(bmain); if (CTX_wm_window(C) == NULL) { /* in rare cases this could happen, when trying to invoke in background @@ -2620,10 +2620,10 @@ static int wm_open_mainfile__select_file_path(bContext *C, wmOperator *op) /* if possible, get the name of the most recently used .blend file */ if (G.recent_files.first) { struct RecentFile *recent = G.recent_files.first; - openname = recent->filepath; + blendfile_path = recent->filepath; } - RNA_string_set(op->ptr, "filepath", openname); + RNA_string_set(op->ptr, "filepath", blendfile_path); wm_open_init_load_ui(op, true); wm_open_init_use_scripts(op, true); op->customdata = NULL; @@ -3610,10 +3610,10 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, uiItemL_ex(layout, TIP_("Save changes before closing?"), ICON_NONE, true, false); /* Filename. */ - const char *blendfile_pathpath = BKE_main_blendfile_path(CTX_data_main(C)); + const char *blendfile_path = BKE_main_blendfile_path(CTX_data_main(C)); char filename[FILE_MAX]; - if (blendfile_pathpath[0] != '\0') { - BLI_split_file_part(blendfile_pathpath, filename, sizeof(filename)); + if (blendfile_path[0] != '\0') { + BLI_split_file_part(blendfile_path, filename, sizeof(filename)); } else { STRNCPY(filename, "untitled.blend"); -- cgit v1.2.3