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
This commit is contained in:
Campbell Barton
2023-10-05 13:33:37 +11:00
parent ed7b7c2cde
commit f5b71e5152
6 changed files with 17 additions and 14 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);