Fix #145719: Crash when using Capture Screenshot Preview

When an asset in the current file is loaded from a user asset library,
weak references to it will have `asset_library_type` set to
`ASSET_LIBRARY_CUSTOM` and not `ASSET_LIBRARY_LOCAL`. Its
`relative_asset_identifier` will, however, be relative to the current
file (`Object/Cube`) instead of to the asset library's root
(`cube.blend/Object/Cube`). This combination makes loading such assets
from a weak reference fail, leading to a null dereference when using the
Capture Screenshot Preview operator.

To fix this, make such assets be loaded with `asset_library_type` set to
`ASSET_LIBRARY_LOCAL` instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/145967
This commit is contained in:
Jorn Visser
2025-09-09 12:55:37 +02:00
committed by Julian Eisel
parent 18d3f0a1a5
commit 227052de83

View File

@@ -3034,7 +3034,11 @@ static void filelist_readjob_asset_library(FileListReadJob *job_params,
filelist_readjob_load_asset_library_data(job_params, do_update);
if (filelist_contains_main(filelist, job_params->current_main)) {
asset_system::AssetLibrary *original_file_library = job_params->load_asset_library;
job_params->load_asset_library = AS_asset_library_load(
job_params->current_main, asset_system::current_file_library_reference());
filelist_readjob_main_assets_add_items(job_params, stop, do_update, progress);
job_params->load_asset_library = original_file_library;
}
if (!job_params->only_main_data) {
filelist_readjob_recursive_dir_add_items(true, job_params, stop, do_update, progress);