From d2f47017b984a50c2bf9ff355fb1d01865663d39 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Jun 2022 15:41:36 +0200 Subject: Fix crash editing anisotropic filter preference from background mode --- source/blender/gpu/intern/gpu_context.cc | 2 +- source/blender/gpu/intern/gpu_texture.cc | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc index c6eaf7defdc..b7dad589395 100644 --- a/source/blender/gpu/intern/gpu_context.cc +++ b/source/blender/gpu/intern/gpu_context.cc @@ -177,7 +177,7 @@ void GPU_render_step() /** \name Backend selection * \{ */ -static GPUBackend *g_backend; +static GPUBackend *g_backend = nullptr; bool GPU_backend_supported(eGPUBackendType type) { diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index d78dc845074..c300c0da3b2 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -702,7 +702,11 @@ void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *r_size) void GPU_samplers_update() { - GPUBackend::get()->samplers_update(); + /* Backend may not exist when we are updating preferences from background mode. */ + GPUBackend *backend = GPUBackend::get(); + if (backend) { + backend->samplers_update(); + } } /** \} */ -- cgit v1.2.3