diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/speaker.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/world.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_bpath.h | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 27 |
19 files changed, 66 insertions, 58 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 77ce7a50956..59ced28d53e 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -59,7 +59,7 @@ int id_copy(struct ID *id, struct ID **newid, int test); int id_unlink(struct ID *id, int test); int new_id(struct ListBase *lb, struct ID *id, const char *name); -void id_clear_lib_data(struct ListBase *lb, struct ID *id); +void id_clear_lib_data(struct Main *bmain, struct ID *id); struct ListBase *which_libbase(struct Main *mainlib, short type); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index ac0697ddbf9..d02a1d6dd27 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -137,14 +137,14 @@ void make_local_action(bAction *act) // XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default if ((act->id.flag & LIB_FAKEUSER) && (act->id.us<=1)) { - id_clear_lib_data(&bmain->action, (ID *)act); + id_clear_lib_data(bmain, (ID *)act); return; } BKE_animdata_main_cb(bmain, make_localact_init_cb, &mlac); if (mlac.local && mlac.lib==0) { - id_clear_lib_data(&bmain->action, (ID *)act); + id_clear_lib_data(bmain, (ID *)act); } else if (mlac.local && mlac.lib) { mlac.actn= copy_action(act); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index c1675faf053..b4b5dfedad2 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -141,7 +141,7 @@ void make_local_armature(bArmature *arm) if (arm->id.lib==NULL) return; if (arm->id.us==1) { - id_clear_lib_data(&bmain->armature, (ID *)arm); + id_clear_lib_data(bmain, (ID *)arm); return; } @@ -153,7 +153,7 @@ void make_local_armature(bArmature *arm) } if(local && lib==0) { - id_clear_lib_data(&bmain->armature, (ID *)arm); + id_clear_lib_data(bmain, (ID *)arm); } else if(local && lib) { bArmature *armn= copy_armature(arm); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 45558329d4d..511f90f3d26 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -201,7 +201,7 @@ void make_local_brush(Brush *brush) if(brush->clone.image) { /* special case: ima always local immediately. Clone image should only have one user anyway. */ - id_clear_lib_data(&bmain->brush, (ID *)brush->clone.image); + id_clear_lib_data(bmain, (ID *)brush->clone.image); extern_local_brush(brush); } @@ -213,7 +213,7 @@ void make_local_brush(Brush *brush) } if(local && lib==0) { - id_clear_lib_data(&bmain->brush, (ID *)brush); + id_clear_lib_data(bmain, (ID *)brush); extern_local_brush(brush); /* enable fake user by default */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 4d93f2cba05..f5335bb12cd 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -255,7 +255,7 @@ void make_local_curve(Curve *cu) if(cu->id.lib==NULL) return; if(cu->id.us==1) { - id_clear_lib_data(&bmain->curve, (ID *)cu); + id_clear_lib_data(bmain, (ID *)cu); extern_local_curve(cu); return; } @@ -268,7 +268,7 @@ void make_local_curve(Curve *cu) } if(local && lib==0) { - id_clear_lib_data(&bmain->curve, (ID *)cu); + id_clear_lib_data(bmain, (ID *)cu); extern_local_curve(cu); } else if(local && lib) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5f7d2d40acc..986b3acf6b0 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -323,7 +323,8 @@ static void extern_local_image(Image *UNUSED(ima)) match id_make_local pattern. */ } -void make_local_image(struct Image *ima) { +void make_local_image(struct Image *ima) +{ Main *bmain= G.main; Tex *tex; Brush *brush; @@ -339,9 +340,9 @@ void make_local_image(struct Image *ima) { /* Can't take short cut here: must check meshes at least because of bogus texface ID refs. - z0r */ -#if(0) +#if 0 if(ima->id.us==1) { - id_clear_lib_data(&bmain->image, (ID *)ima); + id_clear_lib_data(bmain, (ID *)ima); extern_local_image(ima); return; } @@ -380,16 +381,17 @@ void make_local_image(struct Image *ima) { } if(local && lib==0) { - id_clear_lib_data(&bmain->image, (ID *)ima); + id_clear_lib_data(bmain, (ID *)ima); extern_local_image(ima); } else if(local && lib) { Image *iman= copy_image(ima); + char *user_data[2]= {bmain->name, iman->id.lib->filepath}; + iman->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id((ID *)iman, bpath_relocate_visitor, - ((ID *)ima)->lib->filepath); + bpath_traverse_id(&iman->id, bpath_relocate_visitor, user_data); tex= bmain->tex.first; while(tex) { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index ebf5492625b..d90cda19ea9 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -255,7 +255,7 @@ void make_local_lattice(Lattice *lt) if(lt->id.lib==NULL) return; if(lt->id.us==1) { - id_clear_lib_data(&bmain->latt, (ID *)lt); + id_clear_lib_data(bmain, (ID *)lt); return; } @@ -267,7 +267,7 @@ void make_local_lattice(Lattice *lt) } if(local && lib==0) { - id_clear_lib_data(&bmain->latt, (ID *)lt); + id_clear_lib_data(bmain, (ID *)lt); } else if(local && lib) { Lattice *ltn= copy_lattice(lt); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0c2ca4c68b3..308fa828271 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1250,12 +1250,13 @@ int new_id(ListBase *lb, ID *id, const char *tname) /* Pull an ID out of a library (make it local). Only call this for IDs that don't have other library users. */ -void id_clear_lib_data(ListBase *lb, ID *id) +void id_clear_lib_data(Main *bmain, ID *id) { - bpath_traverse_id(id, bpath_relocate_visitor, id->lib->filepath); + char *user_data[2]= {bmain->name, id->lib->filepath}; + bpath_traverse_id(id, bpath_relocate_visitor, user_data); id->lib= NULL; id->flag= LIB_LOCAL; - new_id(lb, id, NULL); + new_id(which_libbase(bmain, GS(id->name)), id, NULL); } /* next to indirect usage in read/writefile also in editobject.c scene.c */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 12d92d57e86..4fd2c3ff2fc 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -297,7 +297,7 @@ void make_local_material(Material *ma) /* One local user; set flag and return. */ if(ma->id.us==1) { - id_clear_lib_data(&bmain->mat, (ID *)ma); + id_clear_lib_data(bmain, (ID *)ma); extern_local_material(ma); return; } @@ -359,7 +359,7 @@ void make_local_material(Material *ma) /* Only local users. */ if(local && lib==0) { - id_clear_lib_data(&bmain->mat, (ID *)ma); + id_clear_lib_data(bmain, (ID *)ma); extern_local_material(ma); } /* Both user and local, so copy. */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 2c6a3b80d94..db493b33ced 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -156,7 +156,7 @@ void make_local_mball(MetaBall *mb) if(mb->id.lib==NULL) return; if(mb->id.us==1) { - id_clear_lib_data(&bmain->mball, (ID *)mb); + id_clear_lib_data(bmain, (ID *)mb); extern_local_mball(mb); return; @@ -170,7 +170,7 @@ void make_local_mball(MetaBall *mb) } if(local && lib==0) { - id_clear_lib_data(&bmain->mball, (ID *)mb); + id_clear_lib_data(bmain, (ID *)mb); extern_local_mball(mb); } else if(local && lib) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a5bf39d895c..5c7d9278783 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -280,7 +280,7 @@ void make_local_mesh(Mesh *me) if(me->id.lib==NULL) return; if(me->id.us==1) { - id_clear_lib_data(&bmain->mesh, (ID *)me); + id_clear_lib_data(bmain, (ID *)me); expand_local_mesh(me); return; } @@ -293,7 +293,7 @@ void make_local_mesh(Mesh *me) } if(local && lib==0) { - id_clear_lib_data(&bmain->mesh, (ID *)me); + id_clear_lib_data(bmain, (ID *)me); expand_local_mesh(me); } else if(local && lib) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6a3e0353a07..824e59a82c5 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1050,7 +1050,7 @@ void ntreeMakeLocal(bNodeTree *ntree) if(ntree->id.lib==NULL) return; if(ntree->id.us==1) { - id_clear_lib_data(&bmain->nodetree, (ID *)ntree); + id_clear_lib_data(bmain, (ID *)ntree); return; } @@ -1064,7 +1064,7 @@ void ntreeMakeLocal(bNodeTree *ntree) /* if all users are local, we simply make tree local */ if(cd.local && cd.lib==0) { - id_clear_lib_data(&bmain->nodetree, (ID *)ntree); + id_clear_lib_data(bmain, (ID *)ntree); } else if(cd.local && cd.lib) { /* this is the mixed case, we copy the tree and assign it to local users */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6e09aefeea2..819a98248f9 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -756,7 +756,7 @@ void make_local_camera(Camera *cam) if(cam->id.lib==NULL) return; if(cam->id.us==1) { - id_clear_lib_data(&bmain->camera, (ID *)cam); + id_clear_lib_data(bmain, (ID *)cam); return; } @@ -768,7 +768,7 @@ void make_local_camera(Camera *cam) } if(local && lib==0) { - id_clear_lib_data(&bmain->camera, (ID *)cam); + id_clear_lib_data(bmain, (ID *)cam); } else if(local && lib) { Camera *camn= copy_camera(cam); @@ -917,7 +917,7 @@ void make_local_lamp(Lamp *la) if(la->id.lib==NULL) return; if(la->id.us==1) { - id_clear_lib_data(&bmain->lamp, (ID *)la); + id_clear_lib_data(bmain, (ID *)la); return; } @@ -931,7 +931,7 @@ void make_local_lamp(Lamp *la) } if(local && lib==0) { - id_clear_lib_data(&bmain->lamp, (ID *)la); + id_clear_lib_data(bmain, (ID *)la); } else if(local && lib) { lan= copy_lamp(la); @@ -1083,7 +1083,6 @@ Object *add_only_object(int type, const char *name) /* ob->pad3 == Contact Processing Threshold */ ob->m_contactProcessingThreshold = 1.; ob->obstacleRad = 1.; - ob->col_group = ob->col_mask = 1; /* NT fluid sim defaults */ ob->fluidsimFlag = 0; @@ -1461,7 +1460,7 @@ void make_local_object(Object *ob) ob->proxy= ob->proxy_from= NULL; if(ob->id.us==1) { - id_clear_lib_data(&bmain->object, (ID *)ob); + id_clear_lib_data(bmain, (ID *)ob); extern_local_object(ob); } else { @@ -1473,7 +1472,7 @@ void make_local_object(Object *ob) } if(local && lib==0) { - id_clear_lib_data(&bmain->object, (ID *)ob); + id_clear_lib_data(bmain, (ID *)ob); extern_local_object(ob); } else if(local && lib) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f478c8faf07..99d7a9af512 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3610,7 +3610,7 @@ void make_local_particlesettings(ParticleSettings *part) if(part->id.lib==0) return; if(part->id.us==1) { - id_clear_lib_data(&bmain->particle, (ID *)part); + id_clear_lib_data(bmain, (ID *)part); expand_local_particlesettings(part); return; } @@ -3627,7 +3627,7 @@ void make_local_particlesettings(ParticleSettings *part) } if(local && lib==0) { - id_clear_lib_data(&bmain->particle, (ID *)part); + id_clear_lib_data(bmain, (ID *)part); expand_local_particlesettings(part); } else if(local && lib) { diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index fb6a473f04d..a01e2eae96e 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -87,7 +87,7 @@ void make_local_speaker(Speaker *spk) if(spk->id.lib==NULL) return; if(spk->id.us==1) { - id_clear_lib_data(&bmain->speaker, (ID *)spk); + id_clear_lib_data(bmain, (ID *)spk); return; } @@ -101,7 +101,7 @@ void make_local_speaker(Speaker *spk) } if(local && lib==0) { - id_clear_lib_data(&bmain->speaker, (ID *)spk); + id_clear_lib_data(bmain, (ID *)spk); } else if(local && lib) { Speaker *spkn= copy_speaker(spk); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index b7fc2835f63..bf4cd84f571 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -814,7 +814,8 @@ Tex *localize_texture(Tex *tex) /* ------------------------------------------------------------------------- */ -static void extern_local_texture(Tex *tex) { +static void extern_local_texture(Tex *tex) +{ id_lib_extern((ID *)tex->ima); } @@ -837,7 +838,7 @@ void make_local_texture(Tex *tex) if(tex->id.lib==NULL) return; if(tex->id.us==1) { - id_clear_lib_data(&bmain->tex, (ID *)tex); + id_clear_lib_data(bmain, (ID *)tex); extern_local_texture(tex); return; } @@ -892,7 +893,7 @@ void make_local_texture(Tex *tex) } if(local && lib==0) { - id_clear_lib_data(&bmain->tex, (ID *)tex); + id_clear_lib_data(bmain, (ID *)tex); extern_local_texture(tex); } else if(local && lib) { diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 150bf7157d9..ca719e58ea9 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -160,7 +160,7 @@ void make_local_world(World *wrld) if(wrld->id.lib==NULL) return; if(wrld->id.us==1) { - id_clear_lib_data(&bmain->world, (ID *)wrld); + id_clear_lib_data(bmain, (ID *)wrld); return; } @@ -172,7 +172,7 @@ void make_local_world(World *wrld) } if(local && lib==0) { - id_clear_lib_data(&bmain->world, (ID *)wrld); + id_clear_lib_data(bmain, (ID *)wrld); } else if(local && lib) { World *wrldn= copy_world(wrld); diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index 5774d90912e..478fe0a4c59 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -54,10 +54,10 @@ void BLI_bpathIterator_setPath (struct BPathIterator *bpi, const char *path) /* Function that does something with an ID's file path. Should return 1 if the path has changed, and in that case, should write the result to pathOut. */ -typedef int (*bpath_visitor)(void *userdata, char *pathIn, char *pathOut); +typedef int (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src); /* Executes 'visit' for each path associated with 'id'. */ -void bpath_traverse_id(struct ID *id, bpath_visitor visit, void *userdata); -int bpath_relocate_visitor(void *oldbasepath, char *pathIn, char *pathOut); +void bpath_traverse_id(struct ID *id, BPathVisitor visit, void *userdata); +int bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src); /* high level funcs */ diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 2884ea2743a..0d22981946e 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -953,14 +953,16 @@ void findMissingFiles(Main *bmain, const char *str) } /* Run a visitor on a string, replacing the contents of the string as needed. */ -static void rewrite_path(char *path, bpath_visitor visit, void *userdata) { +static void rewrite_path(char *path, BPathVisitor visit, void *userdata) +{ char pathOut[FILE_MAX]; if (visit(userdata, path, pathOut)) BLI_strncpy(path, pathOut, FILE_MAX); } /* Run visitor function 'visit' on all paths contained in 'id'. */ -void bpath_traverse_id(ID *id, bpath_visitor visit, void *userdata) { +void bpath_traverse_id(ID *id, BPathVisitor visit, void *userdata) +{ Image *ima; switch(GS(id->name)) { @@ -981,26 +983,29 @@ void bpath_traverse_id(ID *id, bpath_visitor visit, void *userdata) { /* Rewrites a relative path to be relative to the main file - unless the path is absolute, in which case it is not altered. */ -int bpath_relocate_visitor(void *oldbasepath_v, char *pathIn, char *pathOut) { +int bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src) +{ /* be sure there is low chance of the path being too short */ char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - char *oldbasepath = oldbasepath_v; + const char *base_new= ((char **)pathbase_v)[0]; + const char *base_old= ((char **)pathbase_v)[1]; - if (strncmp(oldbasepath, "//", 2) == 0) { - printf("Error: old base path '%s' is not absolute.\n", oldbasepath); + if (strncmp(base_old, "//", 2) == 0) { + printf("%s: error, old base path '%s' is not absolute.\n", + __func__, base_old); return 0; } /* Make referenced file absolute. This would be a side-effect of BLI_cleanup_file, but we do it explicitely so we know if it changed. */ - BLI_strncpy(filepath, pathIn, FILE_MAX); - if (BLI_path_abs(filepath, oldbasepath)) { + BLI_strncpy(filepath, path_src, FILE_MAX); + if (BLI_path_abs(filepath, base_old)) { /* Path was relative and is now absolute. Remap. * Important BLI_cleanup_dir runs before the path is made relative * because it wont work for paths that start with "//../" */ - BLI_cleanup_file(G.main->name, filepath); - BLI_path_rel(filepath, G.main->name); - BLI_strncpy(pathOut, filepath, FILE_MAX); + BLI_cleanup_file(base_new, filepath); + BLI_path_rel(filepath, base_new); + BLI_strncpy(path_dst, filepath, FILE_MAX); return 1; } else { |