Commit: 48ad55a03d658e73ae90166e752f5cf81292c8c1 Author: Campbell Barton Date: Tue Mar 19 13:42:54 2019 +1100 Branches: master https://developer.blender.org/rB48ad55a03d658e73ae90166e752f5cf81292c8c1
Cleanup: use enum for CTX_data_mode_enum Exposes errors in some cases when compared against incompatible values. =================================================================== M source/blender/blenkernel/BKE_context.h M source/blender/blenkernel/intern/context.c M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_manager.c M source/blender/editors/space_buttons/space_buttons.c M source/blender/windowmanager/intern/wm_keymap_utils.c =================================================================== diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index cf573232bac..e9ca3c51a5f 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -254,10 +254,10 @@ struct RenderEngineType *CTX_data_engine_type(const bContext *C); struct ToolSettings *CTX_data_tool_settings(const bContext *C); const char *CTX_data_mode_string(const bContext *C); -int CTX_data_mode_enum_ex( +enum eContextObjectMode CTX_data_mode_enum_ex( const struct Object *obedit, const struct Object *ob, const eObjectMode object_mode); -int CTX_data_mode_enum(const bContext *C); +enum eContextObjectMode CTX_data_mode_enum(const bContext *C); void CTX_data_main_set(bContext *C, struct Main *bmain); void CTX_data_scene_set(bContext *C, struct Scene *bmain); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index a8e0cbed707..a16656253d3 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -975,7 +975,7 @@ Collection *CTX_data_collection(const bContext *C) return BKE_collection_master(scene); } -int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode) +enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode) { // Object *obedit = CTX_data_edit_object(C); if (obedit) { @@ -1015,7 +1015,7 @@ int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectM return CTX_MODE_OBJECT; } -int CTX_data_mode_enum(const bContext *C) +enum eContextObjectMode CTX_data_mode_enum(const bContext *C) { Object *obedit = CTX_data_edit_object(C); Object *obact = obedit ? NULL : CTX_data_active_object(C); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 28a897a4c35..0f79affe44a 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -3750,7 +3750,8 @@ void drw_batch_cache_generate_requested(Object *ob) { const DRWContextState *draw_ctx = DRW_context_state_get(); const ToolSettings *ts = draw_ctx->scene->toolsettings; - const int mode = CTX_data_mode_enum_ex(draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode); + const enum eContextObjectMode mode = CTX_data_mode_enum_ex( + draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode); const bool is_paint_mode = ELEM(mode, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT); const bool use_hide = ( (ob->type == OB_MESH) && diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index d53d5710eb1..e991c69fdc1 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1307,7 +1307,8 @@ static void drw_engines_enable_basic(void) static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_type) { Object *obact = OBACT(view_layer); - const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode); + const enum eContextObjectMode mode = CTX_data_mode_enum_ex( + DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode); View3D *v3d = DST.draw_ctx.v3d; const int drawtype = v3d->shading.type; const bool use_xray = XRAY_ENABLED(v3d); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index acba11ddec7..609ef86b003 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -201,7 +201,7 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceProper static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) { const WorkSpace *workspace = CTX_wm_workspace(C); - const int mode = CTX_data_mode_enum(C); + const enum eContextObjectMode mode = CTX_data_mode_enum(C); const char *contexts_base[5] = {NULL}; contexts_base[0] = ".active_tool"; @@ -260,6 +260,8 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) case CTX_MODE_WEIGHT_GPENCIL: ARRAY_SET_ITEMS(contexts, ".greasepencil_weight"); break; + default: + break; } } else if (workspace->tools_space_type == SPACE_IMAGE) { @@ -295,6 +297,8 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) case CTX_MODE_EDIT_GPENCIL: ARRAY_SET_ITEMS(contexts, ".greasepencil_edit"); break; + default: + break; } int i = 0; diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 6e70511ce63..35bd3a78142 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -258,6 +258,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) case OB_MODE_EDIT: km = WM_keymap_find_all(C, "UV Sculpt", 0, 0); break; + default: + break; } } else if (STRPREFIX(opname, "MBALL_OT")) { @@ -293,6 +295,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) case OB_MODE_TEXTURE_PAINT: km = WM_keymap_find_all(C, "Image Paint", 0, 0); break; + default: + break; } } /* Image Editor */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs