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.

This commit is contained in:
Joseph Eagar 2009-08-06 14:03:43 +00:00
parent 8f5d067c46
commit 7e6662e60c
7 changed files with 53 additions and 16 deletions

@ -75,6 +75,7 @@ extern void BKE_undo_name(struct bContext *C, const char *name);
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

@ -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_Edge;
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

@ -725,11 +725,19 @@ char *BKE_undo_menu_string(void)
/* 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 @@ void BKE_undo_save_quit(void)
/* 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 @@ void BKE_undo_save_quit(void)
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);
}

@ -383,8 +383,8 @@ void poly_rotate_plane(float normal[3], float (*verts)[3], int nverts)
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 @@ void bmesh_update_face_normal(BMesh *bm, BMFace *f, float (*projectverts)[3])
/*
* 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)
{

@ -271,9 +271,15 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op)
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);

@ -1743,5 +1743,5 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot)
/* 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);
}

@ -28,7 +28,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include <signal.h>
/* for setuid / getuid */
#ifdef __sgi
@ -261,19 +261,42 @@ double PIL_check_seconds_timer(void);
}
}*/
#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