Commit: f243390bd685bde392a7f8e132c445f14609f2a4
Author: Bastien Montagne
Date:   Fri May 25 11:29:52 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBf243390bd685bde392a7f8e132c445f14609f2a4

Cleanup: minor details in BKE paint code related to palettes.

* Always use BKE_id_new, unless you have a very good reason to use
lower-level code!
* Prefer to pass actual ID user pointer to functions like id_us_plus & co,
rather than 'floating' ID pointer, when possible. It makes it more clear
who is the user we increase count for!

===================================================================

M       source/blender/blenkernel/intern/paint.c

===================================================================

diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 4056a15fe47..f961510984a 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -338,8 +338,8 @@ void BKE_paint_palette_set(Paint *p, Palette *palette)
 {
        if (p) {
                id_us_min((ID *)p->palette);
-               id_us_plus((ID *)palette);
                p->palette = palette;
+               id_us_plus((ID *)p->palette);
        }
 }
 
@@ -347,8 +347,8 @@ void BKE_paint_curve_set(Brush *br, PaintCurve *pc)
 {
        if (br) {
                id_us_min((ID *)br->paint_curve);
-               id_us_plus((ID *)pc);
                br->paint_curve = pc;
+               id_us_plus((ID *)br->paint_curve);
        }
 }
 
@@ -381,9 +381,7 @@ void BKE_palette_clear(Palette *palette)
 
 Palette *BKE_palette_add(Main *bmain, const char *name)
 {
-       Palette *palette;
-
-       palette = BKE_libblock_alloc(bmain, ID_PAL, name, 0);
+       Palette *palette = BKE_id_new(bmain, ID_PAL, name);
 
        /* enable fake user by default */
        id_fake_user_set(&palette->id);
@@ -424,7 +422,7 @@ void BKE_palette_free(Palette *palette)
 
 PaletteColor *BKE_palette_color_add(Palette *palette)
 {
-       PaletteColor *color = MEM_callocN(sizeof(*color), "Pallete Color");
+       PaletteColor *color = MEM_callocN(sizeof(*color), "Palette Color");
        BLI_addtail(&palette->colors, color);
        return color;
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to