scenes now adjust brush usercounts on copying and freeing, pointed out by Jason Wilkins
authorCampbell Barton <ideasman42@gmail.com>
Mon, 27 Jun 2011 04:05:19 +0000 (04:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 27 Jun 2011 04:05:19 +0000 (04:05 +0000)
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/paint.c

index a4ceb62ab55dcbf2247afc76b88d0a16c9879b39..c497cd2813a84354cce302ff48e42c33cf1ee6b7 100644 (file)
@@ -235,8 +235,6 @@ void make_local_brush(Brush *brush)
                        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--;
                                }
                        }
                }
index 5be492d1108624e6ba751b561ca5592ba09e9b28..d00eb6192da6e59ad65f0841a716f9964c10ad5b 100644 (file)
@@ -85,8 +85,11 @@ Brush *paint_brush(Paint *p)
 
 void paint_brush_set(Paint *p, Brush *br)
 {
-       if(p)
+       if(p) {
+               id_us_min((ID *)p->brush);
+               id_us_plus((ID *)br);
                p->brush= br;
+       }
 }
 
 int paint_facesel_test(Object *ob)
@@ -110,12 +113,17 @@ void paint_init(Paint *p, const char col[3])
        p->flags |= PAINT_SHOW_BRUSH;
 }
 
-void free_paint(Paint *UNUSED(paint))
+void free_paint(Paint *paint)
 {
-       /* nothing */
+       id_us_min((ID *)paint->brush);
 }
 
+/* called when copying scene settings, so even if 'src' and 'tar' are the same
+ * still do a id_us_plus(), rather then if we were copying betweem 2 existing
+ * scenes where a matching value should decrease the existing user count as
+ * with paint_brush_set() */
 void copy_paint(Paint *src, Paint *tar)
 {
        tar->brush= src->brush;
+       id_us_plus((ID *)tar->brush);
 }