Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_edit.c
| Show First 20 Lines • Show All 4,275 Lines • ▼ Show 20 Lines | static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op) | ||||
| const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_src); | const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_src); | ||||
| /* Create a new object. */ | /* Create a new object. */ | ||||
| /* Take into account user preferences for duplicating actions. */ | /* Take into account user preferences for duplicating actions. */ | ||||
| const eDupli_ID_Flags dupflag = (U.dupflag & USER_DUP_ACT); | const eDupli_ID_Flags dupflag = (U.dupflag & USER_DUP_ACT); | ||||
| base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_prev, dupflag); | base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_prev, dupflag); | ||||
| /* Because new bGPdata is a copy: reduce user count. */ | |||||
| id_us_min(&gpd_src->id); | |||||
mont29: better be explicit where we decrease user count from: `id_us_min(ob_dst->data);` or something… | |||||
| ob_dst = base_new->object; | ob_dst = base_new->object; | ||||
| ob_dst->mode = OB_MODE_OBJECT; | ob_dst->mode = OB_MODE_OBJECT; | ||||
| /* create new grease pencil datablock */ | /* create new grease pencil datablock */ | ||||
| gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2); | gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2); | ||||
| ob_dst->data = (bGPdata *)gpd_dst; | ob_dst->data = (bGPdata *)gpd_dst; | ||||
| /* loop old datablock and separate parts */ | /* loop old datablock and separate parts */ | ||||
| if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) { | if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) { | ||||
| ▲ Show 20 Lines • Show All 662 Lines • Show Last 20 Lines | |||||
better be explicit where we decrease user count from: id_us_min(ob_dst->data); or something like that, just before re-assigning to that pointer the new GP id (and add in comment why we do not need to increase usercount of that one as well).