[Bf-blender-cvs] [ee435806235] blender-v2.83-release: Fix usercount not decrementing in `gpencil_stroke_separate_exec`

Philipp Oeser noreply at git.blender.org
Wed Aug 12 09:44:09 CEST 2020


Commit: ee4358062355ac6a4232f32100c62a49bcb1be27
Author: Philipp Oeser
Date:   Wed Jul 29 12:53:49 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBee4358062355ac6a4232f32100c62a49bcb1be27

Fix usercount not decrementing in `gpencil_stroke_separate_exec`

This is part of T79273 where separating a stroke would result in
multiuser gpencil data for the original object.
Real underlying issue seems to be that gpencil multiuser objects (also
the ones created by Alt+D duplicating) have a problem evaluating
modifiers correctly [this will need further investigation].
Not sure if this is a limitation of D5470?

This patch only corrects the usercount on separating [which already fixes
the scenario reported because singleuser gpencil modifiers work
correctly].

Note: we could have also called `ED_object_add_duplicate` with the
`USER_DUP_GPENCIL` dupflag -- that would have taken care of the usercount
--, but then the whole following logic in `gpencil_stroke_separate_exec`
would need to change from **adding** layers/frames/strokes to
**removing** these.

Part of T79273

Maniphest Tasks: T79273

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

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

M	source/blender/editors/gpencil/gpencil_edit.c

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index e2bd1c4a4a9..f54f34728c6 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -4251,8 +4251,11 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
   base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_prev, dupflag);
   ob_dst = base_new->object;
   ob_dst->mode = OB_MODE_OBJECT;
-  /* create new grease pencil datablock */
+  /* Duplication will increment bGPdata usercount, but since we create a new greasepencil datablock
+   * for ob_dst (which gets its own user automatically), we have to decrement the usercount again.
+   */
   gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2);
+  id_us_min(ob_dst->data);
   ob_dst->data = (bGPdata *)gpd_dst;
 
   /* loop old datablock and separate parts */



More information about the Bf-blender-cvs mailing list