[Bf-blender-cvs] [0b6be261261] master: BLF: remove checks for blend file relative paths

Campbell Barton noreply at git.blender.org
Sat Aug 28 11:23:16 CEST 2021


Commit: 0b6be261261151032b6ebfe80320ff198b5df200
Author: Campbell Barton
Date:   Sat Aug 28 17:21:50 2021 +1000
Branches: master
https://developer.blender.org/rB0b6be261261151032b6ebfe80320ff198b5df200

BLF: remove checks for blend file relative paths

This was added in b24712a9ca6fa807660a02d6988269748daecdbf
but is no longer needed as of efc129bc827558e55cf4619b8e2ca502342338f3.

Further, this wasn't reliable as it could fail on linked library data
which has a different base directory.

Assert when blend file relative paths are passed to BLF
(matching imbuf file loading).

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

M	source/blender/blenfont/intern/blf_dir.c

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

diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
index 55c02b34f3d..f4a20faf109 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -47,9 +47,6 @@
 #include "blf_internal.h"
 #include "blf_internal_types.h"
 
-#include "BKE_global.h"
-#include "BKE_main.h"
-
 static ListBase global_font_dir = {NULL, NULL};
 
 static DirBLF *blf_dir_find(const char *path)
@@ -127,6 +124,8 @@ void BLF_dir_free(char **dirs, int count)
 
 char *blf_dir_search(const char *file)
 {
+  BLI_assert_msg(!BLI_path_is_rel(file), "Relative paths must always be expanded!");
+
   DirBLF *dir;
   char full_path[FILE_MAX];
   char *s = NULL;
@@ -140,11 +139,9 @@ char *blf_dir_search(const char *file)
   }
 
   if (!s) {
-    /* Assume file is either an absolute path, or a relative path to current directory. */
-    BLI_strncpy(full_path, file, sizeof(full_path));
-    BLI_path_abs(full_path, BKE_main_blendfile_path(G_MAIN));
-    if (BLI_exists(full_path)) {
-      s = BLI_strdup(full_path);
+    /* This may be an absolute path which exists. */
+    if (BLI_exists(file)) {
+      s = BLI_strdup(file);
     }
   }



More information about the Bf-blender-cvs mailing list