[Bf-blender-cvs] [8ad2642c471] master: Cleanup: use "filepath" term for Main, BlendFileData & FileGlobal

Campbell Barton noreply at git.blender.org
Mon Dec 13 06:22:59 CET 2021


Commit: 8ad2642c4717dcfad31626f7eebac325a9827b73
Author: Campbell Barton
Date:   Mon Dec 13 16:22:19 2021 +1100
Branches: master
https://developer.blender.org/rB8ad2642c4717dcfad31626f7eebac325a9827b73

Cleanup: use "filepath" term for Main, BlendFileData & FileGlobal

Use "filepath" which is the current convention for naming full paths.

- Main use "name" which isn't obviously a file path.
- BlendFileData & FileGlobal used "filename" which is often
  used for the name component of a path (without the directory).

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

M	source/blender/blenkernel/BKE_global.h
M	source/blender/blenkernel/BKE_main.h
M	source/blender/blenkernel/intern/asset_library.cc
M	source/blender/blenkernel/intern/blender_undo.c
M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/blenkernel/intern/bpath_test.cc
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/main.c
M	source/blender/blenloader/BLO_readfile.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/readfile_tempload.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/armature/pose_transform.c
M	source/blender/editors/asset/intern/asset_catalog.cc
M	source/blender/editors/asset/intern/asset_ops.cc
M	source/blender/editors/render/render_preview.c
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/editors/space_clip/clip_ops.c
M	source/blender/freestyle/intern/system/PythonInterpreter.h
M	source/blender/io/alembic/exporter/abc_archive.cc
M	source/blender/makesdna/DNA_fileglobal_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/makesrna/intern/rna_main.c
M	source/blender/python/intern/bpy_rna_data.c
M	source/blender/sequencer/intern/disk_cache.c
M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blender/windowmanager/intern/wm_window.c
M	source/creator/creator_args.c
M	source/creator/creator_signals.c

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

diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 630db07e4d9..1464a905c80 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -50,12 +50,12 @@ typedef struct Global {
   /** Last used location for library link/append. */
   char lib[1024];
 
-  /** When set: `G_MAIN->name` contains valid relative base path. */
+  /** When set: `G_MAIN->filepath` contains valid relative base path. */
   bool relbase_valid;
   /**
    * When set:
-   * - Saving writes to `G_MAIN->name` without prompting for a file-path.
-   * - The title-bar displays `G_MAIN->name`.
+   * - Saving writes to `G_MAIN->filepath` without prompting for a file-path.
+   * - The title-bar displays `G_MAIN->filepath`.
    */
   bool save_over;
 
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 0976671c64c..df5c542db1e 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -116,12 +116,13 @@ enum {
 
 typedef struct Main {
   struct Main *next, *prev;
-  char name[1024];                   /* 1024 = FILE_MAX */
+  char filepath[1024];               /* 1024 = FILE_MAX */
   short versionfile, subversionfile; /* see BLENDER_FILE_VERSION, BLENDER_FILE_SUBVERSION */
   short minversionfile, minsubversionfile;
   uint64_t build_commit_timestamp; /* commit's timestamp from buildinfo */
   char build_hash[16];             /* hash from buildinfo */
-  char recovered;                  /* indicate the main->name (file) is the recovered one */
+  /** Indicate the #Main.filepath (file) is the recovered one. */
+  char recovered;
   /** All current ID's exist in the last memfile undo step. */
   char is_memfile_undo_written;
   /**
diff --git a/source/blender/blenkernel/intern/asset_library.cc b/source/blender/blenkernel/intern/asset_library.cc
index 68e43852a21..74de9b93c25 100644
--- a/source/blender/blenkernel/intern/asset_library.cc
+++ b/source/blender/blenkernel/intern/asset_library.cc
@@ -71,7 +71,7 @@ bool BKE_asset_library_find_suitable_root_path_from_path(const char *input_path,
 
 bool BKE_asset_library_find_suitable_root_path_from_main(const Main *bmain, char *r_library_path)
 {
-  return BKE_asset_library_find_suitable_root_path_from_path(bmain->name, r_library_path);
+  return BKE_asset_library_find_suitable_root_path_from_path(bmain->filepath, r_library_path);
 }
 
 blender::bke::AssetCatalogService *BKE_asset_library_get_catalog_service(
@@ -168,7 +168,7 @@ void AssetLibrary::on_blend_save_post(struct Main *main,
   }
 
   if (save_catalogs_when_file_is_saved) {
-    this->catalog_service->write_to_disk(main->name);
+    this->catalog_service->write_to_disk(main->filepath);
   }
 }
 
diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c
index 411ece21599..6c443a94def 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -68,7 +68,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
                              bContext *C)
 {
   Main *bmain = CTX_data_main(C);
-  char mainstr[sizeof(bmain->name)];
+  char mainstr[sizeof(bmain->filepath)];
   int success = 0, fileflags;
 
   BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
@@ -101,7 +101,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
 
   /* Restore, bmain has been re-allocated. */
   bmain = CTX_data_main(C);
-  BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name));
+  STRNCPY(bmain->filepath, mainstr);
   G.fileflags = fileflags;
 
   if (success) {
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 5ba25d603b8..6ae19c8036f 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -360,12 +360,12 @@ static void setup_app_data(bContext *C,
 
   /* startup.blend or recovered startup */
   if (is_startup) {
-    bmain->name[0] = '\0';
+    bmain->filepath[0] = '\0';
   }
   else if (recover) {
-    /* In case of autosave or quit.blend, use original filename instead. */
+    /* In case of autosave or quit.blend, use original filepath instead. */
     bmain->recovered = 1;
-    BLI_strncpy(bmain->name, bfd->filename, FILE_MAX);
+    STRNCPY(bmain->filepath, bfd->filepath);
   }
 
   /* baseflags, groups, make depsgraph, etc */
@@ -858,8 +858,8 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
                                             BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE);
 
   /* This is needed to be able to load that file as a real one later
-   * (otherwise main->name will not be set at read time). */
-  BLI_strncpy(bmain_dst->name, bmain_src->name, sizeof(bmain_dst->name));
+   * (otherwise `main->filepath` will not be set at read time). */
+  STRNCPY(bmain_dst->filepath, bmain_src->filepath);
 
   BLO_main_expander(blendfile_write_partial_cb);
   BLO_expand_main(NULL, bmain_src);
diff --git a/source/blender/blenkernel/intern/bpath_test.cc b/source/blender/blenkernel/intern/bpath_test.cc
index ee921cc2135..121d47af75f 100644
--- a/source/blender/blenkernel/intern/bpath_test.cc
+++ b/source/blender/blenkernel/intern/bpath_test.cc
@@ -76,7 +76,7 @@ class BPathTest : public testing::Test {
   void SetUp() override
   {
     bmain = BKE_main_new();
-    BLI_strncpy(bmain->name, BLENDFILE_PATH, sizeof(bmain->name));
+    STRNCPY(bmain->filepath, BLENDFILE_PATH);
 
     BKE_id_new(bmain, ID_TXT, nullptr);
     BKE_id_new(bmain, ID_MC, nullptr);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 1efaa9a8c3d..cc6854d2f2e 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -908,7 +908,7 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist
   char str[FILE_MAX], strtest[FILE_MAX];
 
   STRNCPY(str, filepath);
-  BLI_path_abs(str, bmain->name);
+  BLI_path_abs(str, bmain->filepath);
 
   /* first search an identical filepath */
   for (ima = bmain->images.first; ima; ima = ima->id.next) {
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c
index 7254d5d50ee..64731be57ac 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -560,7 +560,7 @@ void BKE_main_thumbnail_create(struct Main *bmain)
 
 const char *BKE_main_blendfile_path(const Main *bmain)
 {
-  return bmain->name;
+  return bmain->filepath;
 }
 
 const char *BKE_main_blendfile_path_from_global(void)
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index f86528db452..8fe0907deab 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -74,7 +74,7 @@ typedef struct BlendFileData {
 
   int fileflags;
   int globalf;
-  char filename[1024]; /* 1024 = FILE_MAX */
+  char filepath[1024]; /* 1024 = FILE_MAX */
 
   struct bScreen *curscreen; /* TODO: think this isn't needed anymore? */
   struct Scene *curscene;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3532918c3b6..ed6687bfa38 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -631,7 +631,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
   //  printf("blo_find_main: converted to %s\n", name1);
 
   for (m = mainlist->first; m; m = m->next) {
-    const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->name;
+    const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->filepath;
 
     if (BLI_path_cmp(name1, libname) == 0) {
       if (G.debug & G_DEBUG) {
@@ -2848,7 +2848,7 @@ static void lib_link_library(BlendLibReader *UNUSED(reader), Library *UNUSED(lib
  * in relation to the blend file. */
 static void fix_relpaths_library(const char *basepath, Main *main)
 {
-  /* BLO_read_from_memory uses a blank filename */
+  /* #BLO_read_from_memory uses a blank file-path. */
   if (basepath == NULL || basepath[0] == '\0') {
     LISTBASE_FOREACH (Library *, lib, &main->libraries) {
       /* when loading a linked lib into a file which has not been saved,
@@ -3502,25 +3502,25 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
 
   bfd->fileflags = fg->fileflags;
   bfd->globalf = fg->globalf;
-  BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
+  STRNCPY(bfd->filepath, fg->filepath);
 
-  /* Error in 2.65 and older: main->name was not set if you save from startup
+  /* Error in 2.65 and older: `main->filepath` was not set if you save from startup
    * (not after loading file). */
-  if (bfd->filename[0] == 0) {
+  if (bfd->filepath[0] == 0) {
     if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) {
       if ((G.fileflags & G_FILE_RECOVER_READ) == 0) {
-        BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
+        STRNCPY(bfd->filepath, BKE_main_blendfile_path(bfd->main));
       }
     }
 
-    /* early 2.50 version patch - filename not in FileGlobal struct at all */
+    /* early 2.50 version patch - filepath not in FileGlobal struct at all */
     if (fd->fileversion <= 250) {
-      BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
+      STRNCPY(bfd->filepath, BKE_main_blendfile_path(bfd->main));
     }
   }
 
   if (G.fileflags & G_FILE_RECOVER_READ) {
-    BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
+    BLI_strncpy(fd->relabase, fg->filepath, sizeof(fd->relabase));
   }
 
   bfd->curscreen = fg->curscreen;
@@ -3616,7 +3616,7 @@ static void do_versions_after_linking(Main *main, ReportList *reports)
   CLOG_INFO(&LOG,
             2,
             "Processing %s (%s), %d.%d",
-            main->curlib ? main->curlib->filepath : main->name,
+            main->curlib ? main->curlib->filepath : main->filepath,
             main->curlib ? "LIB" : "MAIN",
             main->versionfile,
             main->subversionfile);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list