Fix #122036: Preview image crash with asset browser
I can't reproduce this on release or debug builds. But from the strack traces provided in a couple reports, it looks like the runtime pointer is null. This makes sense because BKE_previewimg_blend_read is not called here which is what allocates the runtime struct on file read. To maintain a "valid" PreviewImage in more code and avoid the complexity of making the runtime pointer optional, just allocate it in BLO_blendhandle_get_preview_for_id.
This commit is contained in:
@@ -270,8 +270,9 @@ PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh,
|
||||
if (preview_from_file == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
PreviewImage *result = static_cast<PreviewImage *>(MEM_dupallocN(preview_from_file));
|
||||
result->runtime = MEM_new<blender::bke::PreviewImageRuntime>(__func__);
|
||||
bhead = blo_blendhandle_read_preview_rects(fd, bhead, result, preview_from_file);
|
||||
MEM_freeN(preview_from_file);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user