[project @ 2005-12-11 21:55:25 by bursa]

Show an error box when assert() fails instead of exiting suddenly.

svn path=/import/netsurf/; revision=1897
This commit is contained in:
James Bursa 2005-12-11 21:55:25 +00:00
parent 666cdaf8dd
commit 8552f34816
3 changed files with 49 additions and 3 deletions

View File

@ -1,4 +1,4 @@
| Run file for NetSurf. ( $Revision: 1.41 $ )
| Run file for NetSurf. ( $Revision: 1.42 $ )
|
| This file ensures that the system resources required by NetSurf are
| present. Additionally, it forces setting of system variables related
@ -77,4 +77,4 @@ Unset NetSurf$SpecialFX
Unset Alias$NetSurfRMLoad
WimpSlot -min 2240k -max 2240k
Run <NetSurf$Dir>.!RunImage %*0 2><NetSurf$Dir>.stderr
Run <NetSurf$Dir>.!RunImage %*0 2><Wimp$ScrapDir>.WWW.NetSurf.Log

View File

@ -31,7 +31,7 @@ OBJECTS_IMAGE = gif.o gifread.o jpeg.o mng.o # image/
OBJECTS_RISCOS = $(OBJECTS_COMMON) $(OBJECTS_IMAGE)
OBJECTS_RISCOS += browser.o netsurf.o selection.o textinput.o \
version.o # desktop/
OBJECTS_RISCOS += 401login.o artworks.o awrender.o bitmap.o \
OBJECTS_RISCOS += 401login.o artworks.o assert.o awrender.o bitmap.o \
buffer.o debugwin.o \
dialog.o download.o draw.o filename.o filetype.o font.o \
global_history.o gui.o help.o history.o hotlist.o image.o \

46
riscos/assert.c Normal file
View File

@ -0,0 +1,46 @@
/*
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
* Assert reporting (RISC OS implementation).
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <oslib/wimp.h>
/**
* Report an assert() failure and exit.
*/
void __assert2(const char *expr, const char *function, const char *file,
int line)
{
static const os_error error = { 1, "NetSurf has detected a serious "
"error and must exit. Please submit a bug report, "
"attaching the browser log file." };
fprintf(stderr, "\n\"%s\", line %d: %s%sAssertion failed: %s\n",
file, line,
function ? function : "",
function ? ": " : "",
expr);
fflush(stderr);
xwimp_report_error_by_category(&error,
wimp_ERROR_BOX_GIVEN_CATEGORY |
wimp_ERROR_BOX_CATEGORY_ERROR <<
wimp_ERROR_BOX_CATEGORY_SHIFT,
"NetSurf", "!netsurf",
(osspriteop_area *) 1, "Quit", 0);
xos_cli("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.Log");
abort();
}