From e4cc1c3f2c3e5a85fbf4f7f2757b09544dd556ee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Apr 2011 07:17:21 +0000 Subject: fix [#27178] Material links lost when making mesh data local - making local object data - Curve/Mesh/MBall lost references to linked materials. - joining a linked mesh object into a local one lost the link. As well as these reported bugs, checked all local functions for consistency/correctness and found other cases which would also fail. - making local metaball didn't ensure unique ID name. - make_local_armature() was missing check for object users - main body of code would never run. - local particles didn't set the dupli-group or textures to extern. checked all local functions for consistency/correctness. --- source/blender/blenkernel/intern/brush.c | 33 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern/brush.c') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ac532cca7c6..fa3b756ae27 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -180,14 +180,20 @@ void free_brush(Brush *brush) curvemapping_free(brush->curve); } +static void extern_local_brush(Brush *brush) +{ + id_lib_extern((ID *)brush->mtex.tex); +} + void make_local_brush(Brush *brush) { + /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - - Brush *brushn; + * - only local users: set flag + * - mixed: make copy + */ + + Main *bmain= G.main; Scene *scene; int local= 0, lib= 0; @@ -197,19 +203,22 @@ void make_local_brush(Brush *brush) /* special case: ima always local immediately */ brush->clone.image->id.lib= NULL; brush->clone.image->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)brush->clone.image, NULL); + new_id(&bmain->brush, (ID *)brush->clone.image, NULL); + extern_local_brush(brush); } - for(scene= G.main->scene.first; scene; scene=scene->id.next) + for(scene= bmain->scene.first; scene && ELEM(0, lib, local); scene=scene->id.next) { if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { if(scene->id.lib) lib= 1; else local= 1; } + } if(local && lib==0) { brush->id.lib= NULL; brush->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)brush, NULL); + new_id(&bmain->brush, (ID *)brush, NULL); + extern_local_brush(brush); /* enable fake user by default */ if (!(brush->id.flag & LIB_FAKEUSER)) { @@ -218,17 +227,19 @@ void make_local_brush(Brush *brush) } } else if(local && lib) { - brushn= copy_brush(brush); + Brush *brushn= copy_brush(brush); brushn->id.us= 1; /* only keep fake user */ brushn->id.flag |= LIB_FAKEUSER; - for(scene= G.main->scene.first; scene; scene=scene->id.next) - if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) + for(scene= bmain->scene.first; scene; scene=scene->id.next) { + if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { if(scene->id.lib==NULL) { paint_brush_set(&scene->toolsettings->imapaint.paint, brushn); brushn->id.us++; brush->id.us--; } + } + } } } -- cgit v1.2.3