Fix T60022: Crash when adding grease pencil object to a collection disabled in viewport.
See D4163 Thanks to Habib Gahbiche (@zazizizou) for the fix.
This commit is contained in:
parent
4b2198a96a
commit
a30bdcc142
Notes:
blender-bot
2024-05-02 21:33:31 +02:00
Referenced by issue #60251, Transforming a hidden object (hidden via Outliner>Eye-Icon) crashes Blender application Referenced by issue #60022, 2.8 grease pencil crash when added to hidden collection
|
@ -535,10 +535,9 @@ static const ColorTemplate gp_monkey_pct_pupils = {
|
|||
/* Monkey API */
|
||||
|
||||
/* add a 2D Suzanne (original model created by Matias Mendiola) */
|
||||
void ED_gpencil_create_monkey(bContext *C, float mat[4][4])
|
||||
void ED_gpencil_create_monkey(bContext *C, Object *ob, float mat[4][4])
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
|
|
@ -213,10 +213,9 @@ static const ColorTemplate gp_stroke_material_grey = {
|
|||
/* Stroke API */
|
||||
|
||||
/* add a Simple stroke with colors (original design created by Daniel M. Lara and Matias Mendiola) */
|
||||
void ED_gpencil_create_stroke(bContext *C, float mat[4][4])
|
||||
void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
|
|
@ -137,7 +137,8 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
|
|||
*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil"));
|
||||
|
||||
/* add default sets of colors and brushes */
|
||||
ED_gpencil_add_defaults(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ED_gpencil_add_defaults(C, ob);
|
||||
|
||||
/* add new layer */
|
||||
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);
|
||||
|
@ -245,7 +246,8 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
|
|||
*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil"));
|
||||
|
||||
/* add default sets of colors and brushes */
|
||||
ED_gpencil_add_defaults(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ED_gpencil_add_defaults(C, ob);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1221,16 +1221,15 @@ Object *ED_gpencil_add_object(bContext *C, Scene *UNUSED(scene), const float loc
|
|||
/* define size */
|
||||
BKE_object_obdata_size_init(ob, GP_OBGPENCIL_DEFAULT_SIZE);
|
||||
/* create default brushes and colors */
|
||||
ED_gpencil_add_defaults(C);
|
||||
ED_gpencil_add_defaults(C, ob);
|
||||
|
||||
return ob;
|
||||
}
|
||||
|
||||
/* Helper function to create default colors and drawing brushes */
|
||||
void ED_gpencil_add_defaults(bContext *C)
|
||||
void ED_gpencil_add_defaults(bContext *C, Object *ob)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
|
||||
/* first try to reuse default material */
|
||||
|
|
|
@ -220,13 +220,13 @@ void ED_gpencil_brush_draw_eraser(struct Brush *brush, int x, int y);
|
|||
|
||||
/* ----------- Add Primitive Utilities -------------- */
|
||||
|
||||
void ED_gpencil_create_monkey(struct bContext *C, float mat[4][4]);
|
||||
void ED_gpencil_create_stroke(struct bContext *C, float mat[4][4]);
|
||||
void ED_gpencil_create_monkey(struct bContext *C, struct Object *ob, float mat[4][4]);
|
||||
void ED_gpencil_create_stroke(struct bContext *C, struct Object *ob, float mat[4][4]);
|
||||
|
||||
/* ------------ Object Utilities ------------ */
|
||||
struct Object *ED_gpencil_add_object(
|
||||
struct bContext *C, struct Scene *scene, const float loc[3], unsigned short local_view_bits);
|
||||
void ED_gpencil_add_defaults(struct bContext *C);
|
||||
void ED_gpencil_add_defaults(struct bContext *C, struct Object *ob);
|
||||
/* set object modes */
|
||||
void ED_gpencil_setup_modes(struct bContext *C, struct bGPdata *gpd, int newmode);
|
||||
|
||||
|
|
|
@ -1030,7 +1030,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
|
|||
mul_v3_fl(mat[1], radius);
|
||||
mul_v3_fl(mat[2], radius);
|
||||
|
||||
ED_gpencil_create_stroke(C, mat);
|
||||
ED_gpencil_create_stroke(C, ob, mat);
|
||||
break;
|
||||
}
|
||||
case GP_MONKEY:
|
||||
|
@ -1043,7 +1043,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
|
|||
mul_v3_fl(mat[1], radius);
|
||||
mul_v3_fl(mat[2], radius);
|
||||
|
||||
ED_gpencil_create_monkey(C, mat);
|
||||
ED_gpencil_create_monkey(C, ob, mat);
|
||||
break;
|
||||
}
|
||||
case GP_EMPTY:
|
||||
|
@ -1057,7 +1057,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* if this is a new object, initialise default stuff (colors, etc.) */
|
||||
if (newob) {
|
||||
ED_gpencil_add_defaults(C);
|
||||
ED_gpencil_add_defaults(C, ob);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
Loading…
Reference in New Issue