Cleanup: change enum usage so types are explicitly listed

Structure switch statements so new missing items cause warnings.
This commit is contained in:
2020-09-18 11:06:41 +10:00
parent 1dda60792c
commit 0e78dacb4d
4 changed files with 28 additions and 11 deletions

View File

@@ -415,10 +415,12 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
return "gpencil_sculpt_tool";
case PAINT_MODE_WEIGHT_GPENCIL:
return "gpencil_weight_tool";
default:
/* invalid paint mode */
return NULL;
case PAINT_MODE_INVALID:
break;
}
/* Invalid paint mode. */
return NULL;
}
Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)

View File

@@ -6221,7 +6221,7 @@ static void placeholders_ensure_valid(Main *bmain)
static const char *dataname(short id_code)
{
switch (id_code) {
switch ((ID_Type)id_code) {
case ID_OB:
return "Data from OB";
case ID_ME:

View File

@@ -2257,7 +2257,7 @@ int UI_icon_from_rnaptr(bContext *C, PointerRNA *ptr, int rnaicon, const bool bi
int UI_icon_from_idcode(const int idcode)
{
switch (idcode) {
switch ((ID_Type)idcode) {
case ID_AC:
return ICON_ACTION;
case ID_AR:
@@ -2329,14 +2329,21 @@ int UI_icon_from_idcode(const int idcode)
case ID_SIM:
/* TODO: Use correct icon. */
return ICON_PHYSICS;
default:
return ICON_NONE;
/* No icons for these ID-types. */
case ID_LI:
case ID_IP:
case ID_KE:
case ID_SCR:
case ID_WM:
break;
}
return ICON_NONE;
}
int UI_icon_from_object_mode(const int mode)
{
switch (mode) {
switch ((eObjectMode)mode) {
case OB_MODE_OBJECT:
return ICON_OBJECT_DATAMODE;
case OB_MODE_EDIT:
@@ -2359,9 +2366,8 @@ int UI_icon_from_object_mode(const int mode)
return ICON_POSE_HLT;
case OB_MODE_PAINT_GPENCIL:
return ICON_GREASEPENCIL;
default:
return ICON_NONE;
}
return ICON_NONE;
}
int UI_icon_color_from_collection(const Collection *collection)

View File

@@ -675,7 +675,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
static const char *template_id_browse_tip(const StructRNA *type)
{
if (type) {
switch (RNA_type_to_ID_code(type)) {
switch ((ID_Type)RNA_type_to_ID_code(type)) {
case ID_SCE:
return N_("Browse Scene to be linked");
case ID_OB:
@@ -744,6 +744,15 @@ static const char *template_id_browse_tip(const StructRNA *type)
return N_("Browse Volume Data to be linked");
case ID_SIM:
return N_("Browse Simulation to be linked");
/* Use generic text. */
case ID_LI:
case ID_IP:
case ID_KE:
case ID_VF:
case ID_GR:
case ID_WM:
break;
}
}
return N_("Browse ID data to be linked");