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-04-26 11:17:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-26 11:17:21 +0400
commite4cc1c3f2c3e5a85fbf4f7f2757b09544dd556ee (patch)
tree1d134f4085ba2d90e854c47848c6fc82704667bb /source/blender/blenkernel/intern/brush.c
parent461a7c5c8185d0504c63ddc8de0b2c765e72be4b (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c33
1 files changed, 22 insertions, 11 deletions
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--;
}
+ }
+ }
}
}