Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-02-02 14:19:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-02-02 14:19:34 +0300
commiteb9375fb562cccdccb7062ed1f3d26cd7973bb88 (patch)
treeb5227d19393f5e66156468bda9ff8b1f609edf4b /source
parent35ee34ea6771432b1be9796596c4e0bbcc773b02 (diff)
Fix for indirectly linked libs being converted into direct linked libs. (tried to fix this before but didn't work).
fix_relpaths_library() needs to be called after loading libraries but not during recursive library load.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/readfile.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 769ff541ea4..a382fa17fa5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4067,14 +4067,24 @@ static void lib_link_library(FileData *fd, Main *main)
Library *lib;
for(lib= main->library.first; lib; lib= lib->id.next) {
lib->id.us= 1;
-#if 0
+ }
+}
+
+/* Always call this once you havbe loaded new library data to set the relative paths correctly in relation to the blend file */
+static void fix_relpaths_library(const char *basepath, Main *main)
+{
+ Library *lib;
+ /* BLO_read_from_memory uses a blank filename */
+ if (basepath==NULL || basepath[0] == '\0')
+ return;
+
+ for(lib= main->library.first; lib; lib= lib->id.next) {
/* Libraries store both relative and abs paths, recreate relative paths,
* relative to the blend file since indirectly linked libs will be relative to their direct linked library */
if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */
strncpy(lib->name, lib->filename, sizeof(lib->name));
- BLI_makestringcode(fd->filename, lib->name);
+ BLI_makestringcode(basepath, lib->name);
}
-#endif
}
}
@@ -7499,6 +7509,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r)
lib_link_all(fd, bfd->main);
lib_verify_nodetree(bfd->main);
+ fix_relpaths_library(fd->filename, bfd->main); /* make all relative paths, relative to the open blend file */
if(fg)
link_global(fd, bfd, fg); /* as last */
@@ -8456,6 +8467,7 @@ static Library* library_append( Scene *scene, char* file, char *dir, int idcode,
lib_link_all(fd, G.main);
lib_verify_nodetree(G.main);
+ fix_relpaths_library(G.sce, G.main); /* make all relative paths, relative to the open blend file */
/* give a base to loose objects. If group append, do it for objects too */
if(idcode==ID_GR) {
@@ -8715,10 +8727,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
if(mainptr->curlib->filedata) blo_freefiledata(mainptr->curlib->filedata);
mainptr->curlib->filedata= NULL;
-
}
}
+
/* reading runtime */
BlendFileData *blo_read_blendafterruntime(int file, int actualsize, BlendReadError *error_r)