From 49c61e169bb4114b63d99d842c27d533b8733f82 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Jul 2013 15:07:57 +0000 Subject: [PATCH] misc edits - fix for missing None check with recent 'Hidden Wire' draw option. - avoid int overflow with mesh selection. - remove ';' outside of functions. --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++-- source/blender/blenlib/intern/BLI_kdopbvh.c | 3 ++- source/blender/editors/mask/mask_select.c | 4 ++-- source/blender/editors/mesh/editmesh_select.c | 6 +++--- source/blender/editors/mesh/meshtools.c | 4 ++-- source/blender/editors/sculpt_paint/paint_utils.c | 2 +- source/blender/imbuf/intern/jpeg.c | 2 +- source/blender/makesrna/intern/rna_mesh.c | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index fcd1529bb44..a5c8e7727b2 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2540,7 +2540,7 @@ class VIEW3D_PT_view3d_display(Panel): view = context.space_data scene = context.scene gs = scene.game_settings - ob = context.object + obj = context.object col = layout.column() col.prop(view, "show_only_render") @@ -2580,7 +2580,7 @@ class VIEW3D_PT_view3d_display(Panel): if view.use_matcap: col.template_icon_view(view, "matcap_icon") col.prop(view, "show_backface_culling") - if ob.mode == 'EDIT' and view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}: + if obj and obj.mode == 'EDIT' and view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}: col.prop(view, "show_occlude_wire") layout.separator() diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index cd5c961d982..a4c72aa26b0 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -72,7 +72,7 @@ struct BVHTree { /* optimization, ensure we stay small */ BLI_STATIC_ASSERT((sizeof(void *) == 8 && sizeof(BVHTree) <= 48) || (sizeof(void *) == 4 && sizeof(BVHTree) <= 32), - "over sized"); + "over sized") typedef struct BVHOverlapData { BVHTree *tree1, *tree2; @@ -603,6 +603,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->branches_on_level[0] = 1; /* We could stop the loop first (but I am lazy to find out when) */ + /* note: this often causes integer overflow, may be worth avoiding? - campbell */ for (depth = 1; depth < 32; depth++) { data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type; data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type; diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 74d4f31754a..c524aeb06ee 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -812,12 +812,12 @@ static int mask_select_more_less(bContext *C, bool more) int i; bool start_sel, end_sel, prev_sel, cur_sel, cyclic = spline->flag & MASK_SPLINE_CYCLIC; - // reselect point if any handle is selected to make the result more predictable + /* reselect point if any handle is selected to make the result more predictable */ for (i = 0; i < spline->tot_point; i++) { BKE_mask_point_select_set(spline->points + i, MASKPOINT_ISSEL_ANY(spline->points + i)); } - // select more/less does not affect empty/single point splines + /* select more/less does not affect empty/single point splines */ if (spline->tot_point < 2) { continue; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 7ec1113a75f..313974d1b9d 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -460,7 +460,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const bool sel, c 0, NULL, NULL); } - eve = BM_vert_at_index(vc->em->bm, index - 1); + eve = index ? BM_vert_at_index(vc->em->bm, index - 1) : NULL; if (eve && distance < *r_dist) { *r_dist = distance; @@ -552,7 +552,7 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, float *r_dist) view3d_validate_backbuf(vc); index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_solidoffs, bm_wireoffs, &distance, 0, NULL, NULL); - eed = BM_edge_at_index(vc->em->bm, index - 1); + eed = index ? BM_edge_at_index(vc->em->bm, index - 1) : NULL; if (eed && distance < *r_dist) { *r_dist = distance; @@ -625,7 +625,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) view3d_validate_backbuf(vc); index = view3d_sample_backbuf(vc, vc->mval[0], vc->mval[1]); - efa = BM_face_at_index(vc->em->bm, index - 1); + efa = index ? BM_face_at_index(vc->em->bm, index - 1) : NULL; if (efa) { struct { float mval_fl[2]; float dist; BMFace *toFace; } data; diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 950482df555..d0adfc20f79 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1200,7 +1200,7 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index = view3d_sample_backbuf(&vc, mval[0], mval[1]); } - if ((*index) <= 0 || (*index) > (unsigned int)me->totpoly) + if ((*index) == 0 || (*index) > (unsigned int)me->totpoly) return false; (*index)--; @@ -1321,7 +1321,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index = view3d_sample_backbuf(&vc, mval[0], mval[1]); } - if ((*index) <= 0 || (*index) > (unsigned int)me->totvert) + if ((*index) == 0 || (*index) > (unsigned int)me->totvert) return false; (*index)--; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 8db9215a376..3ecde56b5d0 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -333,7 +333,7 @@ int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int *index, /* sample only on the exact position */ *index = view3d_sample_backbuf(vc, mval[0], mval[1]); - if ((*index) <= 0 || (*index) > (unsigned int)totface) { + if ((*index) == 0 || (*index) > (unsigned int)totface) { return 0; } diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 9bb625a64b0..ed4f6d40cee 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -61,7 +61,7 @@ /* the types are from the jpeg lib */ static void jpeg_error(j_common_ptr cinfo) #ifdef __GNUC__ -__attribute__((noreturn)); +__attribute__((noreturn)) #endif ; static void init_source(j_decompress_ptr cinfo); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 15a3861b778..51aad755e77 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -972,7 +972,7 @@ static int rna_Mesh_polygon_string_layers_length(PointerRNA *ptr) } /* Skin vertices */ -DEFINE_CUSTOMDATA_LAYER_COLLECTION(skin_vertice, vdata, CD_MVERT_SKIN); +DEFINE_CUSTOMDATA_LAYER_COLLECTION(skin_vertice, vdata, CD_MVERT_SKIN) static char *rna_MeshSkinVertexLayer_path(PointerRNA *ptr) {