From f5b71e5152d253a18bbc19db387b0909fa026156 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Oct 2023 13:33:37 +1100 Subject: [PATCH] Cleanup: rename Global "lib" & "ima" for clarity Rename members to make it clear they're for the last used file-paths: - ima -> filepath_last_image - lib -> filepath_last_library --- source/blender/blenkernel/BKE_global.h | 4 ++-- source/blender/blenkernel/intern/blender.cc | 2 +- source/blender/blenkernel/intern/image_save.cc | 7 ++++--- source/blender/editors/space_image/image_ops.cc | 2 +- .../blender/windowmanager/intern/wm_files_link.cc | 14 ++++++++------ .../blender/windowmanager/intern/wm_init_exit.cc | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index ad11f72984f..17b5621f14d 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -37,9 +37,9 @@ typedef struct Global { struct Main *pr_main; /** Last saved location for images. */ - char ima[1024]; /* 1024 = FILE_MAX */ + char filepath_last_image[/*FILE_MAX*/ 1024]; /** Last used location for library link/append. */ - char lib[1024]; + char filepath_last_library[/*FILE_MAX*/ 1024]; /** * Strings of recently opened files to show in the file menu. diff --git a/source/blender/blenkernel/intern/blender.cc b/source/blender/blenkernel/intern/blender.cc index fa576b424e8..32d954a2292 100644 --- a/source/blender/blenkernel/intern/blender.cc +++ b/source/blender/blenkernel/intern/blender.cc @@ -181,7 +181,7 @@ void BKE_blender_globals_init() BKE_blender_globals_main_replace(BKE_main_new()); - STRNCPY(G.ima, "//"); + STRNCPY(G.filepath_last_image, "//"); #ifndef WITH_PYTHON_SECURITY /* default */ G.f |= G_FLAG_SCRIPT_AUTOEXEC; diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index d5c3460d0d0..e94b6134c0c 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -165,10 +165,10 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, /* check for empty path */ if (guess_path && opts->filepath[0] == 0) { - const bool is_prev_save = !STREQ(G.ima, "//"); + const bool is_prev_save = !STREQ(G.filepath_last_image, "//"); if (opts->save_as_render) { if (is_prev_save) { - STRNCPY(opts->filepath, G.ima); + STRNCPY(opts->filepath, G.filepath_last_image); } else { BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", DATA_("untitled")); @@ -178,7 +178,8 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, else { BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", ima->id.name + 2); BLI_path_make_safe(opts->filepath); - BLI_path_abs(opts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain)); + BLI_path_abs(opts->filepath, + is_prev_save ? G.filepath_last_image : BKE_main_blendfile_path(bmain)); } /* append UDIM marker if not present */ diff --git a/source/blender/editors/space_image/image_ops.cc b/source/blender/editors/space_image/image_ops.cc index d8d9686e840..d0061f98090 100644 --- a/source/blender/editors/space_image/image_ops.cc +++ b/source/blender/editors/space_image/image_ops.cc @@ -1854,7 +1854,7 @@ static bool save_image_op( WM_cursor_wait(false); /* Remember file path for next save. */ - STRNCPY(G.ima, opts->filepath); + STRNCPY(G.filepath_last_image, opts->filepath); WM_main_add_notifier(NC_IMAGE | NA_EDITED, ima); diff --git a/source/blender/windowmanager/intern/wm_files_link.cc b/source/blender/windowmanager/intern/wm_files_link.cc index 9e9005820e8..3c8da275603 100644 --- a/source/blender/windowmanager/intern/wm_files_link.cc +++ b/source/blender/windowmanager/intern/wm_files_link.cc @@ -99,8 +99,8 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent * /* { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { const char *blendfile_path = BKE_main_blendfile_path_from_global(); - if (G.lib[0] != '\0') { - RNA_string_set(op->ptr, "filepath", G.lib); + if (G.filepath_last_library[0] != '\0') { + RNA_string_set(op->ptr, "filepath", G.filepath_last_library); } else if (blendfile_path[0] != '\0') { char dirpath[FILE_MAX]; @@ -388,8 +388,9 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* recreate dependency graph to include new objects */ DEG_relations_tag_update(bmain); - /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */ - STRNCPY(G.lib, root); + /* TODO: align `G.filepath_last_library` with other directory storage + * (like last opened image, etc). */ + STRNCPY(G.filepath_last_library, root); WM_event_add_notifier(C, NC_WINDOW, nullptr); @@ -786,8 +787,9 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload) BKE_blendfile_link_append_context_free(lapp_context); - /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */ - STRNCPY(G.lib, root); + /* TODO: align `G.filepath_last_library` with other directory storage + * (like last opened image, etc). */ + STRNCPY(G.filepath_last_library, root); BKE_main_lib_objects_recalc_all(bmain); IMB_colormanagement_check_file_config(bmain); diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index 397872cb6c1..0e37577c32e 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -363,7 +363,7 @@ void WM_init(bContext *C, int argc, const char **argv) blender::ui::string_search::read_recent_searches_file(); } - STRNCPY(G.lib, BKE_main_blendfile_path_from_global()); + STRNCPY(G.filepath_last_library, BKE_main_blendfile_path_from_global()); CTX_py_init_set(C, true); WM_keyconfig_init(C);