Fix crash in grease pencil snap without a window region

Add window region check to the poll function.
This commit is contained in:
Campbell Barton
2025-05-22 03:15:13 +00:00
parent 991d48a9ed
commit 9c421cbef2

View File

@@ -3359,8 +3359,16 @@ static bool grease_pencil_snap_poll(bContext *C)
return false;
}
ScrArea *area = CTX_wm_area(C);
return (area != nullptr) && (area->spacetype == SPACE_VIEW3D);
const ScrArea *area = CTX_wm_area(C);
if (!(area && area->spacetype == SPACE_VIEW3D)) {
return false;
}
const ARegion *region = CTX_wm_region(C);
if (!(region && region->regiontype == RGN_TYPE_WINDOW)) {
return false;
}
return true;
}
static wmOperatorStatus grease_pencil_snap_to_grid_exec(bContext *C, wmOperator * /*op*/)