Fix: Crash when trying to poll the status of non-existent icons

This fixes a specific crash that would happen to me sometimes when changing
between files (the files may have been saved in older versions of the Blender).
The fix is just to null-check the icon lookup.

Pull Request: https://projects.blender.org/blender/blender/pulls/111670
This commit is contained in:
Colin Basnett 2023-09-05 16:05:12 +02:00 committed by Julian Eisel
parent 22e4e94d57
commit c73bdce8f8
1 changed files with 2 additions and 2 deletions

View File

@ -417,13 +417,13 @@ Icon *BKE_icon_get(const int icon_id)
bool BKE_icon_is_preview(const int icon_id)
{
const Icon *icon = BKE_icon_get(icon_id);
return icon->obj_type == ICON_DATA_PREVIEW;
return icon != nullptr && icon->obj_type == ICON_DATA_PREVIEW;
}
bool BKE_icon_is_image(const int icon_id)
{
const Icon *icon = BKE_icon_get(icon_id);
return icon->obj_type == ICON_DATA_IMBUF;
return icon != nullptr && icon->obj_type == ICON_DATA_IMBUF;
}
void BKE_icon_set(const int icon_id, Icon *icon)