Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2020-07-29 13:53:49 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-07-30 13:47:54 +0300
commit4251a87bf60eece32ae9ff7a7c481f029a1d2d84 (patch)
tree1b0676c6622bc142454034bd2c1f25b92e4dcd55
parent2bc017ece147bd5556ca524fb9989ab79789f30c (diff)
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
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c5
1 files changed, 4 insertions, 1 deletions
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 */