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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-05-18 09:21:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-18 09:21:44 +0400
commitedb9045824064267e6efe27f58069b69bfc833f8 (patch)
treece977ac36eae1426dccb8a04ee4af93fda90c682 /source/blender/blenloader
parentdc500038248e3edc47347c6de4fd7d0312ace54f (diff)
fix [#27405] Append objects with linked materials they dissapears after save
when linking in files to an unsaved blend file, make all library paths absolute.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index d6d9a4c88c9..e669be2281d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5511,20 +5511,31 @@ static void lib_link_library(FileData *UNUSED(fd), Main *main)
}
}
-/* Always call this once you havbe loaded new library data to set the relative paths correctly in relation to the blend file */
+/* Always call this once you have 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->filepath, sizeof(lib->name));
- BLI_path_rel(lib->name, basepath);
+ if (basepath==NULL || basepath[0] == '\0') {
+ for(lib= main->library.first; lib; lib= lib->id.next) {
+ /* when loading a linked lib into a file which has not been saved,
+ * there is nothing we can be relative to, so instead we need to make
+ * it absolute. This can happen when appending an object with a relative
+ * link into an unsaved blend file. See [#27405].
+ * The remap relative option will make it relative again on save - campbell */
+ if (strncmp(lib->name, "//", 2)==0) {
+ strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ }
+ }
+ }
+ else {
+ 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->filepath, sizeof(lib->name));
+ BLI_path_rel(lib->name, basepath);
+ }
}
}
}