diff options
author | Hans Goudey <h.goudey@me.com> | 2021-02-18 01:42:20 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-02-18 01:42:20 +0300 |
commit | 5fef212e3185b23051da6889d4fe08645249d217 (patch) | |
tree | 274c816eb8a94d5dbb066d73804c20f26e5e254e /source/blender | |
parent | fd75f7c135747b6fb4e53a0a277ad432ec7bfa08 (diff) |
Cleanup: Use const argument, decrease variable scope
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 15 |
2 files changed, 6 insertions, 11 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 67cd4f020be..75100326fac 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1411,7 +1411,7 @@ enum { UI_TEMPLATE_ID_FILTER_AVAILABLE = 1, }; -int UI_icon_from_id(struct ID *id); +int UI_icon_from_id(const struct ID *id); int UI_icon_from_report_type(int type); int UI_icon_colorid_from_report_type(int type); int UI_text_colorid_from_report_type(int type); diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index af058264f25..824fb6272f6 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -511,21 +511,15 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, } /***************************** ID Utilities *******************************/ -int UI_icon_from_id(ID *id) +int UI_icon_from_id(const ID *id) { - Object *ob; - PointerRNA ptr; - short idcode; - if (id == NULL) { return ICON_NONE; } - idcode = GS(id->name); - /* exception for objects */ - if (idcode == ID_OB) { - ob = (Object *)id; + if (GS(id->name) == ID_OB) { + Object *ob = (Object *)id; if (ob->type == OB_EMPTY) { return ICON_EMPTY_DATA; @@ -535,7 +529,8 @@ int UI_icon_from_id(ID *id) /* otherwise get it through RNA, creating the pointer * will set the right type, also with subclassing */ - RNA_id_pointer_create(id, &ptr); + PointerRNA ptr; + RNA_id_pointer_create((ID *)id, &ptr); return (ptr.type) ? RNA_struct_ui_icon(ptr.type) : ICON_NONE; } |