diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2022-03-07 19:04:10 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-03-07 19:04:10 +0300 |
commit | 5dca3ee6a23f002b59c78c54da53c9f45e2d1173 (patch) | |
tree | 88a2a0b3b673a53370710e5cbdbfdb665759c38e | |
parent | ea3b2e8736164e01d7fc5630eb7c7adbc01c8bc4 (diff) |
Fix T95256: Crash when creating off-screen pose asset
Fix crash when creating a pose asset for which the file list entry in
the asset browser is scrolled off-screen. Because of the
off-screen-ness, it wasn't loaded into memory, which eventually caused
an unexpected NULL pointer.
The solution was to use a different function (`filelist_file_find_id`)
that can reliably find the file list entry, after which the cache entry
can be created.
Reviewed by: Severin
Differential Revision: https://developer.blender.org/D14265
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index f9783d1b19f..8182ed2624c 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -531,19 +531,15 @@ void ED_fileselect_activate_by_id(SpaceFile *sfile, ID *asset_id, const bool def FileSelectParams *params = ED_fileselect_get_active_params(sfile); struct FileList *files = sfile->files; - const int num_files_filtered = filelist_files_ensure(files); - for (int file_index = 0; file_index < num_files_filtered; ++file_index) { - const FileDirEntry *file = filelist_file_ex(files, file_index, false); - - if (filelist_file_get_id(file) != asset_id) { - continue; - } - - params->active_file = file_index; - filelist_entry_select_set(files, file, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); - break; + const int file_index = filelist_file_find_id(files, asset_id); + const FileDirEntry *file = filelist_file_ex(files, file_index, true); + if (file == NULL) { + return; } + params->active_file = file_index; + filelist_entry_select_set(files, file, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); + WM_main_add_notifier(NC_ASSET | NA_ACTIVATED, NULL); WM_main_add_notifier(NC_ASSET | NA_SELECTED, NULL); } |