From 45b8a61bf39dade4efcad16c26324d1cb2e95d48 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel <brechtvanlommel@pandora.be> Date: Sat, 5 Nov 2011 10:48:43 +0000 Subject: [PATCH] Fix #29162: grease pencil did not decrement user count on adding new datablock to replace an existing one. --- source/blender/editors/gpencil/gpencil_edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c915bc9ea37..d481be94bcc 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -183,7 +183,10 @@ static int gp_data_add_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - /* just add new datablock now */ + /* decrement user count and add new datablock */ + bGPdata *gpd= (*gpd_ptr); + + id_us_min(&gpd->id); *gpd_ptr= gpencil_data_addnew("GPencil"); } @@ -231,7 +234,7 @@ static int gp_data_unlink_exec (bContext *C, wmOperator *op) /* just unlink datablock now, decreasing its user count */ bGPdata *gpd= (*gpd_ptr); - gpd->id.us--; + id_us_min(&gpd->id); *gpd_ptr= NULL; } -- GitLab