From 5de109cc2d220ca3bd731216b9cd521269ad663e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Dec 2021 11:38:10 +1100 Subject: 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 --- source/blender/editors/util/ed_util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/util') diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 8e94dc23085..882f140c063 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -352,6 +352,7 @@ void unpack_menu(bContext *C, uiLayout *layout; char line[FILE_MAX + 100]; wmOperatorType *ot = WM_operatortype_find(opname, 1); + const char *blendfile_path = BKE_main_blendfile_path(bmain); pup = UI_popup_menu_begin(C, IFACE_("Unpack File"), ICON_NONE); layout = UI_popup_menu_layout(pup); @@ -361,13 +362,13 @@ void unpack_menu(bContext *C, RNA_enum_set(&props_ptr, "method", PF_REMOVE); RNA_string_set(&props_ptr, "id", id_name); - if (G.relbase_valid) { + if (blendfile_path[0] != '\0') { char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; BLI_split_file_part(abs_name, fi, sizeof(fi)); BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); if (!STREQ(abs_name, local_name)) { - switch (BKE_packedfile_compare_to_file(BKE_main_blendfile_path(bmain), local_name, pf)) { + switch (BKE_packedfile_compare_to_file(blendfile_path, local_name, pf)) { case PF_CMP_NOFILE: BLI_snprintf(line, sizeof(line), TIP_("Create %s"), local_name); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); @@ -400,7 +401,7 @@ void unpack_menu(bContext *C, } } - switch (BKE_packedfile_compare_to_file(BKE_main_blendfile_path(bmain), abs_name, pf)) { + switch (BKE_packedfile_compare_to_file(blendfile_path, abs_name, pf)) { case PF_CMP_NOFILE: BLI_snprintf(line, sizeof(line), TIP_("Create %s"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); -- cgit v1.2.3