svn merge -r37793:37865 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / blenkernel / intern / paint.c
index fa6ecb09f4869c7c02eac256e3155047184b6a4a..9a0fc541bcedddd479b71d3913ec5586640f8367 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)
@@ -114,12 +117,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);
 }