Remove G.save_over

The difference between G.save_over and G.relbase_valid was minor.

There is one change in functionality. When saving the default-startup
file from an already loaded blend file - future save actions will
continue to write to the originally loaded file instead of prompting
the user to select a location to save the file.

This change makes saving the startup file behave the same way
"Save a Copy" does.

Reviewed By: brecht

Ref D13556
This commit is contained in:
Campbell Barton 2021-12-14 09:42:46 +11:00
parent a603bb3459
commit 2a0a6a0541
4 changed files with 4 additions and 19 deletions

View File

@ -52,12 +52,6 @@ typedef struct Global {
/** When set: `G_MAIN->filepath` contains valid relative base path. */
bool relbase_valid;
/**
* When set:
* - Saving writes to `G_MAIN->filepath` without prompting for a file-path.
* - The title-bar displays `G_MAIN->filepath`.
*/
bool save_over;
/**
* Strings of recently opened files to show in the file menu.

View File

@ -957,11 +957,9 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* 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;
G.relbase_valid = 0;
}
@ -1357,9 +1355,6 @@ void wm_homefile_read_ex(bContext *C,
WM_check(C); /* opens window(s), checks keymaps */
bmain->filepath[0] = '\0';
/* start with save preference untitled.blend */
G.save_over = 0;
}
{
@ -1850,8 +1845,6 @@ static bool wm_file_write(bContext *C,
if (use_save_as_copy == false) {
G.relbase_valid = 1;
STRNCPY(bmain->filepath, filepath); /* is guaranteed current file */
G.save_over = 1; /* disable untitled.blend convention */
}
SET_FLAG_FROM_TEST(G.fileflags, fileflags & G_FILE_COMPRESS, G_FILE_COMPRESS);
@ -2126,7 +2119,6 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
printf("ok\n");
BKE_report(op->reports, RPT_INFO, "Startup file saved");
G.save_over = 0;
BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_POST);
@ -3011,7 +3003,7 @@ void WM_OT_recover_auto_save(wmOperatorType *ot)
static void wm_filepath_default(char *filepath)
{
if (G.save_over == false) {
if (G.relbase_valid == false) {
BLI_path_filename_ensure(filepath, FILE_MAX, "untitled.blend");
}
}
@ -3022,7 +3014,7 @@ static void save_set_compress(wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "compress");
if (!RNA_property_is_set(op->ptr, prop)) {
if (G.save_over) { /* keep flag for existing file */
if (G.relbase_valid) { /* keep flag for existing file */
RNA_property_boolean_set(op->ptr, prop, (G.fileflags & G_FILE_COMPRESS) != 0);
}
else { /* use userdef for new file */
@ -3210,7 +3202,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U
}
}
if (G.save_over) {
if (G.relbase_valid) {
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);

View File

@ -428,7 +428,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
}
else if (win->ghostwin) {
/* this is set to 1 if you don't have startup.blend open */
if (G.save_over && BKE_main_blendfile_path_from_global()[0]) {
if (G.relbase_valid && BKE_main_blendfile_path_from_global()[0]) {
char str[sizeof(((Main *)NULL)->filepath) + 24];
BLI_snprintf(str,
sizeof(str),

View File

@ -1996,7 +1996,6 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
* save at the filename from the CLI. */
STRNCPY(G_MAIN->filepath, filename);
G.relbase_valid = true;
G.save_over = true;
printf("... opened default scene instead; saving will write to: %s\n", filename);
}
else {