Fix crash when clicking in window while Blender starts

A mouse click in the window will trigger the `VIEW3D_OT_cursor3d` operator
before the viewport is available. This causes a segfault in
`GPU_viewport_engines_data_validate()`.

Other callers of `WM_draw_region_get_viewport()` already check for `NULL`
being returned and handle it gracefully.

Reviewed By: jbakker, fclem

Differential Revision: https://developer.blender.org/D5216
This commit is contained in:
Sybren A. Stüvel 2019-07-10 12:32:10 +02:00
parent f9232c080d
commit 12ceea0434
1 changed files with 5 additions and 1 deletions

View File

@ -804,7 +804,11 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
GPU_depth_test(true);
GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
/* When Blender is starting, a click event can trigger a depth test while the viewport is not
* yet available. */
if (viewport != NULL) {
DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
}
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_disable();