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
committerJeroen Bakker <jeroen@blender.org>2020-08-12 10:04:37 +0300
commitee4358062355ac6a4232f32100c62a49bcb1be27 (patch)
tree1b4eaa4a087d54719abe67e8f0c016ef78ffb69b
parent2c68c925243707df50f54fbc49f43916f9bc1e4a (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 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 */