Fix #124518: Crash modifying material and marking it as an asset in quick succession

The preview generation job is not safe from cases when the underlying data is
changed outside of the job.

Ideally we'd solve possible threading conflict by making the job somehow
smarter. Until then kill the preview job manually, following similar pattern
from other places (for example, lib_id_generate_preview_exec).

Pull Request: https://projects.blender.org/blender/blender/pulls/131372
This commit is contained in:
Sergey Sharybin
2024-12-04 14:56:41 +01:00
committed by Sergey Sharybin
parent e06acd302a
commit 76d6d169ba

View File

@@ -25,6 +25,7 @@
#include "ED_asset_list.hh"
#include "ED_asset_mark_clear.hh"
#include "ED_asset_type.hh"
#include "ED_render.hh"
#include "WM_types.hh"
@@ -56,6 +57,8 @@ bool mark_id(ID *id)
void generate_preview(const bContext *C, ID *id)
{
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
PreviewImage *preview = BKE_previewimg_id_get(id);
if (preview) {
BKE_previewimg_clear(preview);