Fix T94439: Some GPencil operators crash when calling from console
This fix avoid the segment fault for several operators.
This commit is contained in:
@@ -142,6 +142,9 @@ static bool gpencil_bake_ob_list(bContext *C, Depsgraph *depsgraph, Scene *scene
|
||||
|
||||
/* Add active object. In some files this could not be in selected array. */
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
if (obact == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obact->type == OB_MESH) {
|
||||
elem = MEM_callocN(sizeof(GpBakeOb), __func__);
|
||||
|
@@ -968,6 +968,9 @@ static int dash_segment_add_exec(bContext *C, wmOperator *op)
|
||||
DashGpencilModifierData *dmd = (DashGpencilModifierData *)gpencil_edit_modifier_property_get(
|
||||
op, ob, eGpencilModifierType_Dash);
|
||||
|
||||
if (dmd == NULL) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
const int new_active_index = dmd->segment_active_index + 1;
|
||||
DashGpencilModifierSegment *new_segments = MEM_malloc_arrayN(
|
||||
dmd->segments_len + 1, sizeof(DashGpencilModifierSegment), __func__);
|
||||
@@ -1032,6 +1035,10 @@ static int dash_segment_remove_exec(bContext *C, wmOperator *op)
|
||||
DashGpencilModifierData *dmd = (DashGpencilModifierData *)gpencil_edit_modifier_property_get(
|
||||
op, ob, eGpencilModifierType_Dash);
|
||||
|
||||
if (dmd == NULL) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
if (dmd->segment_active_index < 0 || dmd->segment_active_index >= dmd->segments_len) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -1108,6 +1115,10 @@ static int dash_segment_move_exec(bContext *C, wmOperator *op)
|
||||
DashGpencilModifierData *dmd = (DashGpencilModifierData *)gpencil_edit_modifier_property_get(
|
||||
op, ob, eGpencilModifierType_Dash);
|
||||
|
||||
if (dmd == NULL) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
if (dmd->segments_len < 2) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
Reference in New Issue
Block a user