[Bf-blender-cvs] [a573d7e8a14] master: Cleanup: rename Library.filepath to filepath_abs

Campbell Barton noreply at git.blender.org
Tue Jun 23 03:30:55 CEST 2020


Commit: a573d7e8a14ce5e49b8c05ff762a00e181e905aa
Author: Campbell Barton
Date:   Tue Jun 23 09:54:07 2020 +1000
Branches: master
https://developer.blender.org/rBa573d7e8a14ce5e49b8c05ff762a00e181e905aa

Cleanup: rename Library.filepath to filepath_abs

Make it clear that this is the absolute path,
allow the 'name' to be renamed to 'filepath'.

Rename is safe since this is only for run-time.

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

M	source/blender/blenkernel/intern/blender_copybuffer.c
M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/packedFile.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenloader/intern/blend_validate.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/makesdna/DNA_ID.h
M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_files_link.c

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

diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index bd133ce9ea6..e950e94655a 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -100,7 +100,7 @@ bool BKE_copybuffer_read(Main *bmain_dst,
   BKE_main_lib_objects_recalc_all(bmain_dst);
   IMB_colormanagement_check_file_config(bmain_dst);
   /* Append, rather than linking. */
-  Library *lib = BLI_findstring(&bmain_dst->libraries, libname, offsetof(Library, filepath));
+  Library *lib = BLI_findstring(&bmain_dst->libraries, libname, offsetof(Library, filepath_abs));
   BKE_library_make_local(bmain_dst, lib, NULL, true, false);
   /* Important we unset, otherwise these object wont
    * link into other scenes from this blend file.
@@ -155,7 +155,7 @@ int BKE_copybuffer_paste(bContext *C,
   IMB_colormanagement_check_file_config(bmain);
 
   /* append, rather than linking */
-  lib = BLI_findstring(&bmain->libraries, libname, offsetof(Library, filepath));
+  lib = BLI_findstring(&bmain->libraries, libname, offsetof(Library, filepath_abs));
   BKE_library_make_local(bmain, lib, NULL, true, false);
 
   /* important we unset, otherwise these object wont
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 4d36530fccc..ce98d76531f 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -114,7 +114,7 @@ IDTypeInfo IDType_ID_LINK_PLACEHOLDER = {
  * Also note that the id _must_ have a library - campbell */
 static void lib_id_library_local_paths(Main *bmain, Library *lib, ID *id)
 {
-  const char *bpath_user_data[2] = {BKE_main_blendfile_path(bmain), lib->filepath};
+  const char *bpath_user_data[2] = {BKE_main_blendfile_path(bmain), lib->filepath_abs};
 
   BKE_bpath_traverse_id(bmain,
                         id,
@@ -225,7 +225,7 @@ void id_us_ensure_real(ID *id)
         CLOG_ERROR(&LOG,
                    "ID user count error: %s (from '%s')",
                    id->name,
-                   id->lib ? id->lib->filepath : "[Main]");
+                   id->lib ? id->lib->filepath_abs : "[Main]");
         BLI_assert(0);
       }
       id->us = limit + 1;
@@ -283,7 +283,7 @@ void id_us_min(ID *id)
       CLOG_ERROR(&LOG,
                  "ID user decrement error: %s (from '%s'): %d <= %d",
                  id->name,
-                 id->lib ? id->lib->filepath : "[Main]",
+                 id->lib ? id->lib->filepath_abs : "[Main]",
                  id->us,
                  limit);
       if (GS(id->name) != ID_IP) {
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 64ffea22363..f9432eaab3f 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -85,19 +85,19 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
     BLI_strncpy(lib->name, filepath, sizeof(lib->name));
   }
 
-  BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
+  BLI_strncpy(lib->filepath_abs, filepath, sizeof(lib->filepath_abs));
 
-  /* not essential but set filepath is an absolute copy of value which
-   * is more useful if its kept in sync */
-  if (BLI_path_is_rel(lib->filepath)) {
+  /* Not essential but set `filepath_abs` is an absolute copy of value which
+   * is more useful if its kept in sync. */
+  if (BLI_path_is_rel(lib->filepath_abs)) {
     /* note that the file may be unsaved, in this case, setting the
-     * filepath on an indirectly linked path is not allowed from the
+     * `filepath_abs` on an indirectly linked path is not allowed from the
      * outliner, and its not really supported but allow from here for now
      * since making local could cause this to be directly linked - campbell
      */
     /* Never make paths relative to parent lib - reading code (blenloader) always set *all*
      * lib->name relative to current main, not to their parent for indirectly linked ones. */
     const char *basepath = BKE_main_blendfile_path(bmain);
-    BLI_path_abs(lib->filepath, basepath);
+    BLI_path_abs(lib->filepath_abs, basepath);
   }
 }
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 48c6727add5..fc9ec498f86 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3216,7 +3216,7 @@ void BKE_node_clipboard_add_node(bNode *node)
     BLI_strncpy(node_info->id_name, node->id->name, sizeof(node_info->id_name));
     if (ID_IS_LINKED(node->id)) {
       BLI_strncpy(
-          node_info->library_name, node->id->lib->filepath, sizeof(node_info->library_name));
+          node_info->library_name, node->id->lib->filepath_abs, sizeof(node_info->library_name));
     }
     else {
       node_info->library_name[0] = '\0';
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index ff6aa09ec89..476d1a3a91f 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -705,8 +705,8 @@ int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
 
       newname = BKE_packedfile_unpack_to_file(reports,
                                               BKE_main_blendfile_path(bmain),
-                                              lib->filepath,
-                                              lib->filepath,
+                                              lib->filepath_abs,
+                                              lib->filepath_abs,
                                               lib->packedfile,
                                               PF_WRITE_ORIGINAL);
       if (newname != NULL) {
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 836fe59d7bd..298c0b1d78b 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2190,7 +2190,7 @@ static int ptcache_path(PTCacheID *pid, char *filename)
 {
   Library *lib = (pid->ob) ? pid->ob->id.lib : NULL;
   const char *blendfilename = (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH) == 0) ?
-                                  lib->filepath :
+                                  lib->filepath_abs :
                                   BKE_main_blendfile_path_from_global();
   size_t i;
 
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 33c5e3ac197..133811bdc01 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -83,14 +83,14 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
     }
 
     BKE_library_filepath_set(bmain, curlib, curlib->name);
-    BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
+    BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, reports);
 
     if (bh == NULL) {
       BKE_reportf(reports,
                   RPT_ERROR,
                   "Library ID %s not found at expected path %s!",
                   curlib->id.name,
-                  curlib->filepath);
+                  curlib->filepath_abs);
       continue;
     }
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5b5cf8e6232..872c2bf23e8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -310,7 +310,7 @@ void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format,
 /* for reporting linking messages */
 static const char *library_parent_filepath(Library *lib)
 {
-  return lib->parent ? lib->parent->filepath : "<direct>";
+  return lib->parent ? lib->parent->filepath_abs : "<direct>";
 }
 
 /* -------------------------------------------------------------------- */
@@ -673,7 +673,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 : m->name;
+    const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->name;
 
     if (BLI_path_cmp(name1, libname) == 0) {
       if (G.debug & G_DEBUG) {
@@ -697,7 +697,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
   id_us_ensure_real(&lib->id);
 
   BLI_strncpy(lib->name, filepath, sizeof(lib->name));
-  BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
+  BLI_strncpy(lib->filepath_abs, name1, sizeof(lib->filepath_abs));
 
   m->curlib = lib;
 
@@ -8356,12 +8356,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
   /* check if the library was already read */
   for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
     if (newmain->curlib) {
-      if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
+      if (BLI_path_cmp(newmain->curlib->filepath_abs, lib->filepath_abs) == 0) {
         blo_reportf_wrap(fd->reports,
                          RPT_WARNING,
                          TIP_("Library '%s', '%s' had multiple instances, save and reload!"),
                          lib->name,
-                         lib->filepath);
+                         lib->filepath_abs);
 
         change_link_placeholder_to_real_ID_pointer(fd->mainlist, fd, lib, newmain->curlib);
         /*              change_link_placeholder_to_real_ID_pointer_fd(fd, lib, newmain->curlib); */
@@ -8383,12 +8383,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
     }
   }
 
-  /* make sure we have full path in lib->filepath */
-  BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
-  BLI_path_normalize(fd->relabase, lib->filepath);
+  /* Make sure we have full path in lib->filepath_abs */
+  BLI_strncpy(lib->filepath_abs, lib->name, sizeof(lib->name));
+  BLI_path_normalize(fd->relabase, lib->filepath_abs);
 
   //  printf("direct_link_library: name %s\n", lib->name);
-  //  printf("direct

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list