[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22263] branches/bmesh/blender/source: added a crash handler to dump the global undo state to file on segmentation fault .
Joseph Eagar
joeedh at gmail.com
Thu Aug 6 16:03:43 CEST 2009
Revision: 22263
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22263
Author: joeedh
Date: 2009-08-06 16:03:43 +0200 (Thu, 06 Aug 2009)
Log Message:
-----------
added a crash handler to dump the global undo state to file on segmentation fault. it saves to the current file path in G.sce + .crash.blend. note that this code is only enabled on release builds, it's #ifdef'd out if _DEBUG is defined. for users, if you were in edit mode when a crash happened, this will only save the mesh changes up to the time you entered edit mode.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/BKE_blender.h
branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h
branches/bmesh/blender/source/blender/blenkernel/intern/blender.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
branches/bmesh/blender/source/blender/bmesh/operators/utils.c
branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
branches/bmesh/blender/source/creator/creator.c
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_blender.h 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_blender.h 2009-08-06 14:03:43 UTC (rev 22263)
@@ -75,6 +75,7 @@
extern void BKE_reset_undo(void);
extern char *BKE_undo_menu_string(void);
extern void BKE_undo_number(struct bContext *C, int nr);
+void BKE_undo_save(char *fname);
extern void BKE_undo_save_quit(void);
#ifdef __cplusplus
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h 2009-08-06 14:03:43 UTC (rev 22263)
@@ -1,7 +1,7 @@
/**
* BKE_bmesh.h jan 2007
*
- * BMesh modeler structure and functions.
+ * (old) BMesh modeler structure and functions.
*
* $Id$
*
@@ -52,6 +52,7 @@
struct BME_Poly;
struct BME_Loop;
+/*NOTE: this is the bmesh 1.0 code. it's completely outdated.*/
/*Notes on further structure Cleanup:
-Remove the tflags, they belong in custom data layers
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/blender.c 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/blender.c 2009-08-06 14:03:43 UTC (rev 22263)
@@ -726,10 +726,18 @@
/* saves quit.blend */
void BKE_undo_save_quit(void)
{
+ char str[FILE_MAXDIR+FILE_MAXFILE];
+
+ BLI_make_file_string("/", str, btempdir, "quit.blend");
+
+ BKE_undo_save(str);
+}
+
+void BKE_undo_save(char *fname)
+{
UndoElem *uel;
MemFileChunk *chunk;
int file;
- char str[FILE_MAXDIR+FILE_MAXFILE];
if( (U.uiflag & USER_GLOBALUNDO)==0) return;
@@ -742,9 +750,7 @@
/* no undo state to save */
if(undobase.first==undobase.last) return;
- BLI_make_file_string("/", str, btempdir, "quit.blend");
-
- file = open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
+ file = open(fname, O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
if(file == -1) {
//XXX error("Unable to save %s, check you have permissions", str);
return;
@@ -758,7 +764,7 @@
close(file);
- if(chunk) ; //XXX error("Unable to save %s, internal error", str);
- else printf("Saved session recovery to %s\n", str);
+ if(chunk) ; //XXX error("Unable to save %s, internal error", fname);
+ else printf("Saved session recovery to %s\n", fname);
}
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c 2009-08-06 14:03:43 UTC (rev 22263)
@@ -383,8 +383,8 @@
void BM_Face_UpdateNormal(BMesh *bm, BMFace *f)
{
- float projverts[12][3];
- float (*proj)[3] = f->len < 12 ? projverts : MEM_mallocN(sizeof(float)*f->len*3, "projvertsn");
+ float projverts[200][3];
+ float (*proj)[3] = f->len < 200 ? projverts : MEM_mallocN(sizeof(float)*f->len*3, "projvertsn");
BMLoop *l = f->loopbase;
int i=0;
@@ -476,9 +476,9 @@
/*
* BMESH FLIP NORMAL
*
- * Reverses the winding of a faces
- * Note that this does *not* update the calculated
- * Normal
+ * Reverses the winding of a face.
+ * Note that this updates the calculated
+ * normal.
*/
void BM_flip_normal(BMesh *bm, BMFace *f)
{
Modified: branches/bmesh/blender/source/blender/bmesh/operators/utils.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/utils.c 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/blender/bmesh/operators/utils.c 2009-08-06 14:03:43 UTC (rev 22263)
@@ -271,9 +271,15 @@
BM_Compute_Face_Center(bm, startf, cent);
+ /*make sure the starting face has the correct winding*/
if (cent[0]*startf->no[0] + cent[1]*startf->no[1] + cent[2]*startf->no[2] < 0.0)
BM_flip_normal(bm, startf);
+ /*now that we've found our starting face, make all connected faces
+ have the same winding. this is done recursively, using a manual
+ stack (if we use simple function recursion, we'd end up overloading
+ the stack on large meshes).*/
+
V_GROW(fstack);
fstack[0] = startf;
BMO_SetFlag(bm, startf, FACE_VIS);
Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2009-08-06 14:03:43 UTC (rev 22263)
@@ -1743,5 +1743,5 @@
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- RNA_def_int(ot->srna, "repeat", 1, 1, 200, "How many times to smooth the mesh", "", 1, INT_MAX);
+ RNA_def_int(ot->srna, "repeat", 1, 1, 100, "Number of times to smooth the mesh", "", 1, INT_MAX);
}
Modified: branches/bmesh/blender/source/creator/creator.c
===================================================================
--- branches/bmesh/blender/source/creator/creator.c 2009-08-06 13:40:44 UTC (rev 22262)
+++ branches/bmesh/blender/source/creator/creator.c 2009-08-06 14:03:43 UTC (rev 22263)
@@ -28,8 +28,8 @@
*/
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
-
/* for setuid / getuid */
#ifdef __sgi
#include <sys/types.h>
@@ -261,19 +261,42 @@
}
}*/
+#ifndef _DEBUG
+int segmentation_handler(int sig)
+{
+ char fname[256];
+
+ if (!G.sce[0]) {
+ char str[FILE_MAXDIR+FILE_MAXFILE];
+
+ BLI_make_file_string("/", fname, btempdir, "quit.blend");
+ } else
+ sprintf(fname, "%s.crash.blend", G.sce);
+
+ BKE_undo_save(fname);
+
+ /*induce a real crash*/
+ signal(SIGSEGV, SIG_DFL);
+ *(int*)NULL = 0;
+}
+#endif
+
int main(int argc, char **argv)
{
SYS_SystemHandle syshandle;
bContext *C= CTX_create();
int a, i, stax, stay, sizx, sizy /*XXX, scr_init = 0*/;
-
#if defined(WIN32) || defined (__linux__)
int audio = 1;
#else
int audio = 0;
#endif
-
+#ifndef _DEBUG
+ signal(SIGSEGV, segmentation_handler);
+ signal(SIGFPE, segmentation_handler);
+#endif
+
#ifdef WITH_BINRELOC
br_init( NULL );
#endif
More information about the Bf-blender-cvs
mailing list