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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-01-08 16:38:48 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-08 16:38:48 +0300
commit60e70c0c6014e51954473e075a7679ad24648acd (patch)
tree55454702573809436f98d5e6dbee2d13325146de /source/blender/blenkernel/intern/text.c
parent72ca9526411797220ea3b14d63d49c72a15ea2c1 (diff)
Fix T43159: Copying of linked datablocks using relpath leads to invalid paths in new copies.
Simply have to rebase onto main filepath when copying, if source datablock is lib and path is relative. Afaict, only affected Image and Text datablocks. MovieClip would also be a candidate, but has no copy implemented currently.
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r--source/blender/blenkernel/intern/text.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 77629715edb..86c7f6fcd1a 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -446,7 +446,7 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath)
return BKE_text_load_ex(bmain, file, relpath, false);
}
-Text *BKE_text_copy(Text *ta)
+Text *BKE_text_copy(Main *bmain, Text *ta)
{
Text *tan;
TextLine *line, *tmp;
@@ -455,8 +455,17 @@ Text *BKE_text_copy(Text *ta)
/* file name can be NULL */
if (ta->name) {
- tan->name = MEM_mallocN(strlen(ta->name) + 1, "text_name");
- strcpy(tan->name, ta->name);
+ if (ta->id.lib && BLI_path_is_rel(ta->name)) {
+ char tname[FILE_MAXFILE];
+ /* If path is relative, and source is a lib, path is relative to lib file, not main one! */
+ BLI_strncpy(tname, ta->name, sizeof(tname));
+ BLI_path_abs(tname, ta->id.lib->filepath);
+ BLI_path_rel(tname, bmain->name);
+ tan->name = BLI_strdup(tname);
+ }
+ else {
+ tan->name = BLI_strdup(ta->name);
+ }
}
else {
tan->name = NULL;