replace bmesh_error with macro that gives the file/line/func the error happens on.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 26 Feb 2012 14:57:41 +0000 (14:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 26 Feb 2012 14:57:41 +0000 (14:57 +0000)
source/blender/blenkernel/intern/mball.c
source/blender/bmesh/bmesh.h
source/blender/bmesh/bmesh_error.h
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/intern/bmesh_newcore.c
source/blender/bmesh/intern/bmesh_structure.c
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/operators/bmo_subdivide.c

index 2e8c026b75e9270d3e02f86eb03dd965c69b7852..7c0fded5140c4e61a57e02392e6a27fe84fecace 100644 (file)
@@ -2328,7 +2328,6 @@ int BKE_metaball_center_bounds(MetaBall *mb, float cent[3])
 void BKE_metaball_translate(MetaBall *mb, float offset[3])
 {
        MetaElem *ml;
-       int i;
 
        for (ml = mb->elems.first; ml; ml = ml->next) {
                add_v3_v3(&ml->x, offset);
index ace5c79a9286643daca9630da2faf6f2e66a69be..6ea864fe9e3d97f41c3a0c04e0256e76fdcae60d 100644 (file)
@@ -111,7 +111,7 @@ struct EditMesh;
 /* #define BM_ELEM_NONORMCALC (1<<7) */ /* UNUSED */
 
 /* stub */
-void bmesh_error(void);
+void _bmesh_error(const char *at, const char *func);
 
 /* Mesh Level Ops */
 extern int bm_mesh_allocsize_default[4];
index 26f499afd220b0432eb0d690e0a86390268ed67e..2e96599c957af6cdba99d1a94ade52c5c091d860 100644 (file)
@@ -69,4 +69,8 @@ int BMO_error_catch_op(BMesh *bm, BMOperator *catchop, int errorcode, char **msg
 #define BMERR_INVALID_SELECTION                        9
 #define BMERR_MESH_ERROR                               10
 
+
+/* BMESH_ERROR */
+#define BMESH_ERROR _bmesh_error(AT, __func__)
+
 #endif /* __BMESH_ERROR_H__ */
index 097c87ca1c68e4d14fd370d7a0a7bf43f92d889c..7d8e55347f5b1a12447f71ad712ed6a7b8f3fba4 100644 (file)
 int bm_mesh_allocsize_default[4] = {512, 512, 2048, 512};
 
 /* bmesh_error stub */
-void bmesh_error(void)
+void _bmesh_error(const char *at, const char *func)
 {
-       printf("BM modelling error!\n");
+       fprintf(stderr, "BM modelling error '%s', func '%s'!\n", at, func);
 
+#ifdef WITH_ASSERT_ABORT
        /* This placeholder assert makes modelling errors easier to catch
         * in the debugger, until bmesh_error is replaced with something
         * better. */
-       BLI_assert(0);
+       abort();
+#endif
 }
 
 static void bmesh_mempool_init(BMesh *bm, const int allocsize[4])
index d32f516f26e6765ae97d8618296b0aa5214af862..2816c3e491089b6099f32c16500a46b5af5ff985 100644 (file)
@@ -268,14 +268,14 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
        }
 
        if (!jed) {
-               bmesh_error();
+               BMESH_ERROR;
                return NULL;
        }
        
        l1 = jed->l;
        
        if (!l1) {
-               bmesh_error();
+               BMESH_ERROR;
                return NULL;
        }
        
@@ -616,7 +616,7 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **ne, float percen
                                
                                l = e1->l;
                                if (!l) {
-                                       bmesh_error();
+                                       BMESH_ERROR;
                                        break;
                                }
                                
@@ -647,7 +647,7 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **ne, float percen
                        
                        l = e1->l;
                        if (!l) {
-                               bmesh_error();
+                               BMESH_ERROR;
                                break;
                        }
                        
index a03e1512557befbc55c3f71a3c21822e663b3063..dbb44f2cbc3be57857172f0643dcfb7875754e8b 100644 (file)
@@ -452,7 +452,7 @@ int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype)
        }
 
        if (err) {
-               bmesh_error();
+               BMESH_ERROR;
        }
 
        return err;
@@ -792,14 +792,14 @@ static int count_flagged_radial(BMesh *bm, BMLoop *l, int flag)
 
        do {
                if (!l2) {
-                       bmesh_error();
+                       BMESH_ERROR;
                        goto error;
                }
                
                i += BM_ELEM_API_FLAG_TEST(l2->f, flag) ? 1 : 0;
                l2 = bmesh_radial_nextloop(l2);
                if (c >= BM_LOOP_RADIAL_MAX) {
-                       bmesh_error();
+                       BMESH_ERROR;
                        goto error;
                }
                c++;
@@ -891,7 +891,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
        int i, tote = 0;
 
        if (!totface) {
-               bmesh_error();
+               BMESH_ERROR;
                return NULL;
        }
 
@@ -1288,11 +1288,11 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re)
 
        /* verify disk cycle */
        edok = bmesh_disk_validate(valence1, ov->e, ov);
-       if (!edok) bmesh_error();
+       if (!edok) BMESH_ERROR;
        edok = bmesh_disk_validate(valence2, tv->e, tv);
-       if (!edok) bmesh_error();
+       if (!edok) BMESH_ERROR;
        edok = bmesh_disk_validate(2, nv->e, nv);
-       if (!edok) bmesh_error();
+       if (!edok) BMESH_ERROR;
 
        /* Split the radial cycle if presen */
        nextl = e->l;
@@ -1358,21 +1358,21 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re)
 
                /* verify length of radial cycl */
                edok = bmesh_radial_validate(radlen, e->l);
-               if (!edok) bmesh_error();
+               if (!edok) BMESH_ERROR;
                edok = bmesh_radial_validate(radlen, ne->l);
-               if (!edok) bmesh_error();
+               if (!edok) BMESH_ERROR;
 
                /* verify loop->v and loop->next->v pointers for  */
                for (i = 0, l = e->l; i < radlen; i++, l = l->radial_next) {
-                       if (!(l->e == e)) bmesh_error();
-                       //if (!(l->radial_next == l)) bmesh_error();
+                       if (!(l->e == e)) BMESH_ERROR;
+                       //if (!(l->radial_next == l)) BMESH_ERROR;
                        if (l->prev->e != ne && l->next->e != ne) {
-                               bmesh_error();
+                               BMESH_ERROR;
                        }
                        edok = bmesh_verts_in_edge(l->v, l->next->v, e);
-                       if (!edok)               bmesh_error();
-                       if (l->v == l->next->v)  bmesh_error();
-                       if (l->e == l->next->e)  bmesh_error();
+                       if (!edok)               BMESH_ERROR;
+                       if (l->v == l->next->v)  BMESH_ERROR;
+                       if (l->e == l->next->e)  BMESH_ERROR;
 
                        /* verify loop cycle for kloop-> */
                        BM_CHECK_ELEMENT(bm, l);
@@ -1382,13 +1382,13 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re)
                }
                /* verify loop->v and loop->next->v pointers for n */
                for (i = 0, l = ne->l; i < radlen; i++, l = l->radial_next) {
-                       if (!(l->e == ne)) bmesh_error();
-                       //if (!(l->radial_next == l)) bmesh_error();
-                       if (l->prev->e != e && l->next->e != e) bmesh_error();
+                       if (!(l->e == ne)) BMESH_ERROR;
+                       //if (!(l->radial_next == l)) BMESH_ERROR;
+                       if (l->prev->e != e && l->next->e != e) BMESH_ERROR;
                        edok = bmesh_verts_in_edge(l->v, l->next->v, ne);
-                       if (!edok)                bmesh_error();
-                       if (l->v == l->next->v)  bmesh_error();
-                       if (l->e == l->next->e)  bmesh_error();
+                       if (!edok)                BMESH_ERROR;
+                       if (l->v == l->next->v)  BMESH_ERROR;
+                       if (l->e == l->next->e)  BMESH_ERROR;
 
                        BM_CHECK_ELEMENT(bm, l);
                        BM_CHECK_ELEMENT(bm, l->v);
@@ -1525,7 +1525,7 @@ struct BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_e
                                /* Validate radial cycle of o */
                                edok = bmesh_radial_validate(radlen, oe->l);
                                if (!edok) {
-                                       bmesh_error();
+                                       BMESH_ERROR;
                                }
                        }
 
@@ -1537,17 +1537,17 @@ struct BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_e
 
                        /* Validate disk cycle lengths of ov, tv are unchange */
                        edok = bmesh_disk_validate(valence1, ov->e, ov);
-                       if (!edok) bmesh_error();
+                       if (!edok) BMESH_ERROR;
                        edok = bmesh_disk_validate(valence2, tv->e, tv);
-                       if (!edok) bmesh_error();
+                       if (!edok) BMESH_ERROR;
 
                        /* Validate loop cycle of all faces attached to o */
                        for (i = 0, l = oe->l; i < radlen; i++, l = bmesh_radial_nextloop(l)) {
-                               if (l->e != oe) bmesh_error();
+                               if (l->e != oe) BMESH_ERROR;
                                edok = bmesh_verts_in_edge(l->v, l->next->v, oe);
-                               if (!edok) bmesh_error();
+                               if (!edok) BMESH_ERROR;
                                edok = bmesh_loop_validate(l->f);
-                               if (!edok) bmesh_error();
+                               if (!edok) BMESH_ERROR;
 
                                BM_CHECK_ELEMENT(bm, l);
                                BM_CHECK_ELEMENT(bm, l->v);
@@ -1723,7 +1723,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
 
        /* validate the new loop cycle */
        edok = bmesh_loop_validate(f1);
-       if (!edok) bmesh_error();
+       if (!edok) BMESH_ERROR;
        
        return f1;
 }
index 8b16c641c3ad213fb78f0cf5732ce7779f432e84..a90208540b9857dc3975e8dc7d847e73aff7c496 100644 (file)
@@ -366,7 +366,7 @@ int bmesh_radial_validate(int radlen, BMLoop *l)
 
        do {
                if (!l_iter) {
-                       bmesh_error();
+                       BMESH_ERROR;
                        return FALSE;
                }
                
@@ -376,7 +376,7 @@ int bmesh_radial_validate(int radlen, BMLoop *l)
                        return FALSE;
                
                if (i > BM_LOOP_RADIAL_MAX) {
-                       bmesh_error();
+                       BMESH_ERROR;
                        return FALSE;
                }
                
@@ -398,7 +398,7 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e)
 {
        /* if e is non-NULL, l must be in the radial cycle of e */
        if (e && e != l->e) {
-               bmesh_error();
+               BMESH_ERROR;
        }
 
        if (l->radial_next != l) {
@@ -414,7 +414,7 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e)
                                e->l = NULL;
                        }
                        else {
-                               bmesh_error();
+                               BMESH_ERROR;
                        }
                }
        }
@@ -472,13 +472,13 @@ int bmesh_radial_length(BMLoop *l)
        do {
                if (!l_iter) {
                        /* radial cycle is broken (not a circulat loop) */
-                       bmesh_error();
+                       BMESH_ERROR;
                        return 0;
                }
                
                i++;
                if (i >= BM_LOOP_RADIAL_MAX) {
-                       bmesh_error();
+                       BMESH_ERROR;
                        return -1;
                }
        } while ((l_iter = l_iter->radial_next) != l);
@@ -504,7 +504,7 @@ void bmesh_radial_append(BMEdge *e, BMLoop *l)
 
        if (l->e && l->e != e) {
                /* l is already in a radial cycle for a different edge */
-               bmesh_error();
+               BMESH_ERROR;
        }
        
        l->e = e;
index 9cba90c1bf5cb47547cf9ab66508632f17eacf96..4fe54bfaa01d7869019f483db7bfa866aa64dab4 100644 (file)
@@ -89,7 +89,7 @@ void BMW_init(BMWalker *walker, BMesh *bm, int type,
        walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 1");
        
        if (type >= BMW_MAXWALKERS || type < 0) {
-               bmesh_error();
+               BMESH_ERROR;
                fprintf(stderr,
                        "Invalid walker type in BMW_init; type: %d, "
                        "searchmask: (v:%d, e:%d, l:%d, f:%d), flag: %d\n",
index f35d05f69dfb42e23fe897ff47444396ace569a8..9a8f26ddeeb6aae29d808a5eeda38e2655a5d2d6 100644 (file)
@@ -494,8 +494,9 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts
                for (a = 0; a < numcuts; a++) {
                        v = subdivideedgenum(bm, e, &temp, a, numcuts, params, &ne,
                                             v1, v2);
-                       if (!v)
-                               bmesh_error();
+                       if (!v) {
+                               BMESH_ERROR;
+                       }
 
                        BMO_elem_flag_enable(bm, ne, ELE_INNER);
                        lines[(i + 1) * s + a + 1] = v;