[Bf-blender-cvs] [50128e8e79b] master: Avoid Brush user count increase when duplicates the Brush

Antonio Vazquez noreply at git.blender.org
Wed Nov 27 11:30:59 CET 2019


Commit: 50128e8e79bff560d0da6825663543c82286ab17
Author: Antonio  Vazquez
Date:   Wed Nov 27 11:28:22 2019 +0100
Branches: master
https://developer.blender.org/rB50128e8e79bff560d0da6825663543c82286ab17

Avoid Brush user count increase when duplicates the Brush

When you create a new Brush, the user count is `2` (caller and fake user). The problem is when you duplicate a Brush, the user count grows to `3` and this is not correct, because is a new brush.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D6310

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

M	source/blender/editors/sculpt_paint/paint_ops.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index d76403521d9..6252741799a 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -69,8 +69,8 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
   }
   else {
     br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paintmode(mode));
-    id_us_min(&br->id); /* fake user only */
   }
+  id_us_min(&br->id); /* fake user only */
 
   BKE_paint_brush_set(paint, br);
 
@@ -104,12 +104,13 @@ static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op))
   }
   else {
     br = BKE_brush_add(bmain, "Brush", OB_MODE_PAINT_GPENCIL);
-    id_us_min(&br->id); /* fake user only */
 
     /* Init grease pencil specific data. */
     BKE_brush_init_gpencil_settings(br);
   }
 
+  id_us_min(&br->id); /* fake user only */
+
   BKE_paint_brush_set(paint, br);
 
   return OPERATOR_FINISHED;



More information about the Bf-blender-cvs mailing list