diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 12:02:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 12:02:06 +0400 |
commit | e0388a881b668c3c7de8ccb942f360f85243bdbb (patch) | |
tree | 7d8cc5991eed76f97d12470f1d7a218814296347 | |
parent | b3f52205f20c12e88166ac4236fe5e4f26dc848b (diff) |
fix for own error with unwrap selection checking uvedit_have_selection() failed with no UV layer.
also add some safety checks for BM_ELEM_CD_GET_* macros.
-rw-r--r-- | source/blender/bmesh/bmesh.h | 1 | ||||
-rw-r--r-- | source/blender/bmesh/bmesh_class.h | 9 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 6 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 2 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 12 |
5 files changed, 15 insertions, 15 deletions
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index 60d38719ddb..f593f78bab7 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -243,6 +243,7 @@ extern "C" { #include <stdlib.h> #include <stdio.h> +#include <assert.h> #include "bmesh_class.h" diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 824884fb4e4..4fa3a69356f 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -253,18 +253,17 @@ enum { }; /* defines */ - #define BM_ELEM_CD_GET_VOID_P(ele, offset) \ - ((void)0, (void *)((char *)(ele)->head.data + (offset))) + (assert(offset != -1), (void *)((char *)(ele)->head.data + (offset))) #define BM_ELEM_CD_SET_FLOAT(ele, offset, f) \ - { *((float *)((char *)(ele)->head.data + (offset))) = (f); } (void)0 + { assert(offset != -1); *((float *)((char *)(ele)->head.data + (offset))) = (f); } (void)0 #define BM_ELEM_CD_GET_FLOAT(ele, offset) \ - ((void)0, *((float *)((char *)(ele)->head.data + (offset)))) + (assert(offset != -1), *((float *)((char *)(ele)->head.data + (offset)))) #define BM_ELEM_CD_GET_FLOAT_AS_UCHAR(ele, offset) \ - (unsigned char)(BM_ELEM_CD_GET_FLOAT(ele, offset) * 255.0f) + (assert(offset != -1), (unsigned char)(BM_ELEM_CD_GET_FLOAT(ele, offset) * 255.0f)) /*forward declarations*/ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 5eb9bc19cd3..4eff920f8e8 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -271,8 +271,8 @@ typedef struct TransData { } TransData; typedef struct MouseInput { - void (*apply)(struct TransInfo *, struct MouseInput *, const int [2], float [3]); - void (*post)(struct TransInfo *, float [3]); + void (*apply)(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); + void (*post)(struct TransInfo *t, float values[3]); int imval[2]; /* initial mouse position */ char precision; @@ -691,7 +691,7 @@ int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, struct wmEvent void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); void setCustomPoints(TransInfo *t, MouseInput *mi, int start[2], int end[2]); -void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3])); +void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float values[3])); /*********************** Generics ********************************/ diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 69569251d01..37cd10e363c 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -368,7 +368,7 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) applyMouseInput(t, mi, mi->imval, t->values); } -void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float[3])) +void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float values[3])) { mi->post = post; } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 183d76a0892..35e2e291df9 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -161,14 +161,14 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) /****************** Parametrizer Conversion ***************/ -static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, short implicit) +static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit) { BMFace *efa; BMLoop *l; BMIter iter, liter; if (!CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) { - return false; + return (em->bm->totfacesel != 0); } /* verify if we have any selected uv's before unwrapping, @@ -561,7 +561,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); MinStretch *ms; int fill_holes = RNA_boolean_get(op->ptr, "fill_holes"); - short implicit = 1; + bool implicit = true; if (!uvedit_have_selection(scene, em, implicit)) { return false; @@ -757,7 +757,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); ParamHandle *handle; - short implicit = 1; + bool implicit = true; if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; @@ -804,7 +804,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); ParamHandle *handle; - short implicit = 1; + bool implicit = true; if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; @@ -1209,7 +1209,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) int use_subsurf = RNA_boolean_get(op->ptr, "use_subsurf_data"); short use_subsurf_final; float obsize[3]; - short implicit = 0; + bool implicit = false; if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; |