diff options
author | Bastien Montagne <bastien@blender.org> | 2022-05-17 16:08:18 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-05-17 17:06:54 +0300 |
commit | ff2d6c2ba8e8f667a0aac7a79c77b58d87f45a73 (patch) | |
tree | 6c6b54bfa9cf367867e347ee0ac036dc85e475d8 /source/blender/blenkernel/intern/icons.cc | |
parent | c8b740cc0012c7414ac12b569556b0b309ada662 (diff) |
Cleanup: Use `switch` and `BLI_assert_unreachable()` more.
Replace some `if/else if` chains by proper `switch` statement.
Replace some `BLI_assert(0)` calls by `BLI_assert_unreachable()` ones.
Diffstat (limited to 'source/blender/blenkernel/intern/icons.cc')
-rw-r--r-- | source/blender/blenkernel/intern/icons.cc | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index 7826ef9b1f4..f59f5352aad 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -114,32 +114,35 @@ static void icon_free(void *val) static void icon_free_data(int icon_id, Icon *icon) { - if (icon->obj_type == ICON_DATA_ID) { - ((ID *)(icon->obj))->icon_id = 0; - } - else if (icon->obj_type == ICON_DATA_IMBUF) { - ImBuf *imbuf = (ImBuf *)icon->obj; - if (imbuf) { - IMB_freeImBuf(imbuf); + switch (icon->obj_type) { + case ICON_DATA_ID: + ((ID *)(icon->obj))->icon_id = 0; + break; + case ICON_DATA_IMBUF: { + ImBuf *imbuf = (ImBuf *)icon->obj; + if (imbuf) { + IMB_freeImBuf(imbuf); + } + break; } - } - else if (icon->obj_type == ICON_DATA_PREVIEW) { - ((PreviewImage *)(icon->obj))->icon_id = 0; - } - else if (icon->obj_type == ICON_DATA_GPLAYER) { - ((bGPDlayer *)(icon->obj))->runtime.icon_id = 0; - } - else if (icon->obj_type == ICON_DATA_GEOM) { - ((struct Icon_Geom *)(icon->obj))->icon_id = 0; - } - else if (icon->obj_type == ICON_DATA_STUDIOLIGHT) { - StudioLight *sl = (StudioLight *)icon->obj; - if (sl != nullptr) { - BKE_studiolight_unset_icon_id(sl, icon_id); + case ICON_DATA_PREVIEW: + ((PreviewImage *)(icon->obj))->icon_id = 0; + break; + case ICON_DATA_GPLAYER: + ((bGPDlayer *)(icon->obj))->runtime.icon_id = 0; + break; + case ICON_DATA_GEOM: + ((struct Icon_Geom *)(icon->obj))->icon_id = 0; + break; + case ICON_DATA_STUDIOLIGHT: { + StudioLight *sl = (StudioLight *)icon->obj; + if (sl != nullptr) { + BKE_studiolight_unset_icon_id(sl, icon_id); + } + break; } - } - else { - BLI_assert(0); + default: + BLI_assert_unreachable(); } } |