[Bf-blender-cvs] [2a0a6a0541e] master: Remove G.save_over

Campbell Barton noreply at git.blender.org
Mon Dec 13 23:47:26 CET 2021


Commit: 2a0a6a0541eaff06659a06ef18cac05e5674c844
Author: Campbell Barton
Date:   Tue Dec 14 09:42:46 2021 +1100
Branches: master
https://developer.blender.org/rB2a0a6a0541eaff06659a06ef18cac05e5674c844

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

===================================================================

M	source/blender/blenkernel/BKE_global.h
M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_window.c
M	source/creator/creator_args.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 1464a905c80..184ebb8e934 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -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.
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index e753c083805..f3cf5dca040 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -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);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 86abfe881ff..fbced87d19c 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -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),
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 0259e028e63..2d86587d096 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -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 {



More information about the Bf-blender-cvs mailing list