Commit: 4251a87bf60eece32ae9ff7a7c481f029a1d2d84
Author: Philipp Oeser
Date:   Wed Jul 29 12:53:49 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB4251a87bf60eece32ae9ff7a7c481f029a1d2d84

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 f8010edfcdd..286efeeff01 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -4283,8 +4283,11 @@ static int gpencil_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 */

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

Reply via email to