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); | ||||
| ob_dst = base_new->object; | ob_dst = base_new->object; | ||||
| ob_dst->mode = OB_MODE_OBJECT; | ob_dst->mode = OB_MODE_OBJECT; | ||||
mont29: better be explicit where we decrease user count from: `id_us_min(ob_dst->data);` or something… | |||||
| /* 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); | gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2); | ||||
| id_us_min(ob_dst->data); | |||||
| 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)) { | ||||
| CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { | CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { | ||||
| gpl_dst = NULL; | gpl_dst = NULL; | ||||
| bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; | bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; | ||||
| ▲ Show 20 Lines • Show All 658 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).