From 19b36ca24aa6203f63a1dbcafe44e0367665e0bd Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 23 Mar 2023 15:15:56 +0100 Subject: [PATCH] Fix #105325: crash calling asset_generate_preview() in backgound mode `.asset_generate_preview()` internally calls `UI_icon_render_id` as a job -- as opposed to `.preview_ensure()` [which internally also calls `UI_icon_render_id`, but not as a job] leading to crashes in background mode. This might be due to the fact that OpenGL context is not set up correctly (so there might be other ways to fix this), but there seems to be other places/comments indicating that icon handling is only for main thread (see e.g. 13beeb589227). And while this does not fully explain why doing this with jobs works fine from the UI, the patch certainly fixes the crashes in background mode for now (by not using jobs). --- source/blender/editors/asset/intern/asset_mark_clear.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/asset/intern/asset_mark_clear.cc b/source/blender/editors/asset/intern/asset_mark_clear.cc index 276b2f9a2f6..fdc3dc62232 100644 --- a/source/blender/editors/asset/intern/asset_mark_clear.cc +++ b/source/blender/editors/asset/intern/asset_mark_clear.cc @@ -10,6 +10,7 @@ #include "BKE_asset.h" #include "BKE_context.h" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" @@ -52,7 +53,7 @@ void ED_asset_generate_preview(const bContext *C, ID *id) BKE_previewimg_clear(preview); } - UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true); + UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, !G.background); } bool ED_asset_clear_id(ID *id) -- 2.30.2