Fix #54468: crash calling transform operators with incomplete regiondata

If we run into NULL `RegionView3D` `regiondata` [which e.g. happens if
we just set `bpy.context.area.type = 'VIEW_3D'` without further actions
in the text editor prior to calling the transform operator], we can make
it gracefully work just by using `t->spacetype = SPACE_EMPTY` in
`initTransInfo`.

Similar check is already done in ba229e3859 (marked /* running in the
text editor */).

Transform code is smart enough to have fallback code in place that sets
matrices etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/119205
This commit is contained in:
Philipp Oeser 2024-03-11 09:27:32 +01:00
parent e7332f5309
commit 73f313c119

View file

@ -228,8 +228,11 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* background mode */
t->spacetype = SPACE_EMPTY;
}
else if ((region == NULL) && (area->spacetype == SPACE_VIEW3D)) {
/* running in the text editor */
else if (((region == NULL) || (region->regiondata == NULL)) &&
(area->spacetype == SPACE_VIEW3D))
{
/* Running the operator through the text editor where e.g. `area.type` was
* set to 'VIEW_3D' but the viewport was not updated. */
t->spacetype = SPACE_EMPTY;
}
else {