diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-01-10 11:34:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-01-10 11:34:34 +0300 |
commit | bc02c5de497c360449e4de68b3c1432f9bd204de (patch) | |
tree | 111d0c60c82ac0221e47a31846f646aa187348dd /source/blender/blenkernel | |
parent | 3f837341c8f5652f02909d1ebbcf1743ab371847 (diff) |
Alternate fix for brush user count
This reverts change to BKE_brush_add,
callers now remove the extra user.
Note this isn't very convenient for callers but
is consistent with other ID types.
In the future we will probably remove this and have new
ID's created with zero users.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 8ad9cbb2625..0f09b741330 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -148,12 +148,14 @@ void BKE_brush_init(Brush *brush) BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH); } +/** + * \note Resulting brush will have two users: one as a fake user, another is assumed to be used by the caller. + .*/ Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode) { Brush *brush; - /* Use no refcount, fakeuser is added in 'BKE_brush_init' */ - brush = BKE_libblock_alloc(bmain, ID_BR, name, LIB_ID_CREATE_NO_USER_REFCOUNT); + brush = BKE_libblock_alloc(bmain, ID_BR, name, 0); BKE_brush_init(brush); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 32813ffce25..d1e9516f6d2 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -529,8 +529,10 @@ void BKE_paint_init(Scene *sce, ePaintMode mode, const char col[3]) short ob_mode = BKE_paint_object_mode_from_paint_mode(mode); brush = BKE_brush_first_search(G.main, ob_mode); - if (!brush) + if (!brush) { brush = BKE_brush_add(G.main, "Brush", ob_mode); + id_us_min(&brush->id); /* fake user only */ + } BKE_paint_brush_set(paint, brush); } |