Revision: 37839
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37839
Author:   campbellbarton
Date:     2011-06-27 04:05:19 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
scenes now adjust brush usercounts on copying and freeing, pointed out by Jason 
Wilkins

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/blenkernel/intern/paint.c

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c      2011-06-27 
03:54:33 UTC (rev 37838)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c      2011-06-27 
04:05:19 UTC (rev 37839)
@@ -235,8 +235,6 @@
                        
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--;
                                }
                        }
                }

Modified: trunk/blender/source/blender/blenkernel/intern/paint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/paint.c      2011-06-27 
03:54:33 UTC (rev 37838)
+++ trunk/blender/source/blender/blenkernel/intern/paint.c      2011-06-27 
04:05:19 UTC (rev 37839)
@@ -85,8 +85,11 @@
 
 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 @@
        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);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to