Fix T63052: Crash on "Grease Pencil Fill" without Grease Pencil Object

Changed poll function to verify if the context is valid.

Also cleanup return values.
This commit is contained in:
Antonio Vazquez 2019-03-28 16:48:32 +01:00
parent 1be2888bf0
commit 1dddb47e48
Notes: blender-bot 2023-02-14 06:00:44 +01:00
Referenced by issue #63052, Crash on "Grease Pencil Fill" without Grease Pencil Object
1 changed files with 11 additions and 3 deletions

View File

@ -1150,19 +1150,27 @@ static void gpencil_fill_draw_3d(const bContext *C, ARegion *UNUSED(ar), void *a
/* check if context is suitable for filling */
static bool gpencil_fill_poll(bContext *C)
{
Object *obact = CTX_data_active_object(C);
if (ED_operator_regionactive(C)) {
ScrArea *sa = CTX_wm_area(C);
if (sa->spacetype == SPACE_VIEW3D) {
return 1;
if ((obact == NULL) ||
(obact->type != OB_GPENCIL) ||
(obact->mode != OB_MODE_PAINT_GPENCIL)) {
return false;
}
return true;
}
else {
CTX_wm_operator_poll_msg_set(C, "Active region not valid for filling operator");
return 0;
return false;
}
}
else {
CTX_wm_operator_poll_msg_set(C, "Active region not set");
return 0;
return true;
}
}