diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-28 08:44:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-28 08:44:59 +0400 |
commit | 4b635d16316d12dd4c57e1dcf99092551e6bbe35 (patch) | |
tree | 6ea23bd0fe40254564bad60d6113e4362c4f7dd1 /source/blender/blenkernel | |
parent | 3ad7445e28eaf36bf7a7907072205a757cc284d7 (diff) |
use generic path remapping when making all library data local, previously only image paths were getting corrected, now all paths will (scene image seq strips, pointcache etc)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 34 |
2 files changed, 13 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 59ced28d53e..e2033915caa 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -78,7 +78,7 @@ void rename_id(struct ID *id, const char *name); void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); -void all_local(struct Library *lib, int untagged_only); +void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only); struct ID *find_id(const char *type, const char *name); void clear_id_newpoins(void); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index d94e6f844a9..9d8acc44e88 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1277,16 +1277,6 @@ void clear_id_newpoins(void) } } -/* only for library fixes */ -static void image_fix_relative_path(Image *ima) -{ - if(ima->id.lib==NULL) return; - if(strncmp(ima->name, "//", 2)==0) { - BLI_path_abs(ima->name, ima->id.lib->filepath); - BLI_path_rel(ima->name, G.main->name); - } -} - #define LIBTAG(a) if(a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;} static void lib_indirect_test_id(ID *id, Library *lib) @@ -1361,14 +1351,15 @@ void tag_main(struct Main *mainvar, const short tag) } } -/* if lib!=NULL, only all from lib local */ -void all_local(Library *lib, int untagged_only) +/* if lib!=NULL, only all from lib local + * bmain is almost certainly G.main */ +void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) { ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL}; ID *id, *idn; int a; - a= set_listbasepointers(G.main, lbarray); + a= set_listbasepointers(bmain, lbarray); while(a--) { id= lbarray[a]->first; @@ -1385,17 +1376,16 @@ void all_local(Library *lib, int untagged_only) (untagged_only==0 || !(id->flag & LIB_PRE_EXISTING))) { if(lib==NULL || id->lib==lib) { - id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW); - if(id->lib) { - /* relative file patch */ - if(GS(id->name)==ID_IM) - image_fix_relative_path((Image *)id); - - id->lib= NULL; - new_id(lbarray[a], id, NULL); /* new_id only does it with double names */ + id_clear_lib_data(bmain, id); /* sets 'id->flag' */ + + /* why sort alphabetically here but not in + * id_clear_lib_data() ? - campbell */ sort_alpha_id(lbarray[a], id); } + else { + id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW); + } } } id= idn; @@ -1410,7 +1400,7 @@ void all_local(Library *lib, int untagged_only) } /* patch 3: make sure library data isn't indirect falsely... */ - a= set_listbasepointers(G.main, lbarray); + a= set_listbasepointers(bmain, lbarray); while(a--) { for(id= lbarray[a]->first; id; id=id->next) lib_indirect_test_id(id, lib); |