[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44463] trunk/blender/source/blender: replace bmesh_error with macro that gives the file/line/ func the error happens on.

Campbell Barton ideasman42 at gmail.com
Sun Feb 26 15:57:51 CET 2012


Revision: 44463
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44463
Author:   campbellbarton
Date:     2012-02-26 14:57:41 +0000 (Sun, 26 Feb 2012)
Log Message:
-----------
replace bmesh_error with macro that gives the file/line/func the error happens on.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/mball.c
    trunk/blender/source/blender/bmesh/bmesh.h
    trunk/blender/source/blender/bmesh/bmesh_error.h
    trunk/blender/source/blender/bmesh/intern/bmesh_mesh.c
    trunk/blender/source/blender/bmesh/intern/bmesh_mods.c
    trunk/blender/source/blender/bmesh/intern/bmesh_newcore.c
    trunk/blender/source/blender/bmesh/intern/bmesh_structure.c
    trunk/blender/source/blender/bmesh/intern/bmesh_walkers.c
    trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c

Modified: trunk/blender/source/blender/blenkernel/intern/mball.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mball.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/blenkernel/intern/mball.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -2328,7 +2328,6 @@
 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);

Modified: trunk/blender/source/blender/bmesh/bmesh.h
===================================================================
--- trunk/blender/source/blender/bmesh/bmesh.h	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/bmesh.h	2012-02-26 14:57:41 UTC (rev 44463)
@@ -111,7 +111,7 @@
 /* #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];

Modified: trunk/blender/source/blender/bmesh/bmesh_error.h
===================================================================
--- trunk/blender/source/blender/bmesh/bmesh_error.h	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/bmesh_error.h	2012-02-26 14:57:41 UTC (rev 44463)
@@ -69,4 +69,8 @@
 #define BMERR_INVALID_SELECTION			9
 #define BMERR_MESH_ERROR				10
 
+
+/* BMESH_ERROR */
+#define BMESH_ERROR _bmesh_error(AT, __func__)
+
 #endif /* __BMESH_ERROR_H__ */

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_mesh.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_mesh.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -51,14 +51,16 @@
 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])

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_mods.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -268,14 +268,14 @@
 	}
 
 	if (!jed) {
-		bmesh_error();
+		BMESH_ERROR;
 		return NULL;
 	}
 	
 	l1 = jed->l;
 	
 	if (!l1) {
-		bmesh_error();
+		BMESH_ERROR;
 		return NULL;
 	}
 	
@@ -616,7 +616,7 @@
 				
 				l = e1->l;
 				if (!l) {
-					bmesh_error();
+					BMESH_ERROR;
 					break;
 				}
 				
@@ -647,7 +647,7 @@
 			
 			l = e1->l;
 			if (!l) {
-				bmesh_error();
+				BMESH_ERROR;
 				break;
 			}
 			

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_newcore.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_newcore.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -452,7 +452,7 @@
 	}
 
 	if (err) {
-		bmesh_error();
+		BMESH_ERROR;
 	}
 
 	return err;
@@ -792,14 +792,14 @@
 
 	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 @@
 	int i, tote = 0;
 
 	if (!totface) {
-		bmesh_error();
+		BMESH_ERROR;
 		return NULL;
 	}
 
@@ -1288,11 +1288,11 @@
 
 	/* 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 @@
 
 		/* 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 @@
 		}
 		/* 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 @@
 				/* Validate radial cycle of o */
 				edok = bmesh_radial_validate(radlen, oe->l);
 				if (!edok) {
-					bmesh_error();
+					BMESH_ERROR;
 				}
 			}
 
@@ -1537,17 +1537,17 @@
 
 			/* 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 @@
 
 	/* validate the new loop cycle */
 	edok = bmesh_loop_validate(f1);
-	if (!edok) bmesh_error();
+	if (!edok) BMESH_ERROR;
 	
 	return f1;
 }

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_structure.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_structure.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_structure.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -366,7 +366,7 @@
 
 	do {
 		if (!l_iter) {
-			bmesh_error();
+			BMESH_ERROR;
 			return FALSE;
 		}
 		
@@ -376,7 +376,7 @@
 			return FALSE;
 		
 		if (i > BM_LOOP_RADIAL_MAX) {
-			bmesh_error();
+			BMESH_ERROR;
 			return FALSE;
 		}
 		
@@ -398,7 +398,7 @@
 {
 	/* 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 @@
 				e->l = NULL;
 			}
 			else {
-				bmesh_error();
+				BMESH_ERROR;
 			}
 		}
 	}
@@ -472,13 +472,13 @@
 	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 @@
 
 	if (l->e && l->e != e) {
 		/* l is already in a radial cycle for a different edge */
-		bmesh_error();
+		BMESH_ERROR;
 	}
 	
 	l->e = e;

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_walkers.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_walkers.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_walkers.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -89,7 +89,7 @@
 	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",

Modified: trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c	2012-02-26 11:19:40 UTC (rev 44462)
+++ trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c	2012-02-26 14:57:41 UTC (rev 44463)
@@ -494,8 +494,9 @@
 		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;




More information about the Bf-blender-cvs mailing list