X11: Handle X errors via panic
This leaves a usable backtrace for debugging.
This commit is contained in:
@@ -225,6 +225,7 @@ X11: make key translations work with menus on Linux
|
|||||||
X11: allow mouse wheel scrolling to work in menus by default
|
X11: allow mouse wheel scrolling to work in menus by default
|
||||||
X11: handle paged menu control keys
|
X11: handle paged menu control keys
|
||||||
X11: remember perm_invent window geometry
|
X11: remember perm_invent window geometry
|
||||||
|
X11: handle X errors via panic
|
||||||
|
|
||||||
|
|
||||||
General New Features
|
General New Features
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ int click_x, click_y, click_button; /* Click position on a map window */
|
|||||||
/* (filled by set_button_values()). */
|
/* (filled by set_button_values()). */
|
||||||
int updated_inventory;
|
int updated_inventory;
|
||||||
|
|
||||||
|
static int (*old_error_handler) (Display *, XErrorEvent *);
|
||||||
|
|
||||||
#if !defined(NO_SIGNAL) && defined(SAFERHANGUP)
|
#if !defined(NO_SIGNAL) && defined(SAFERHANGUP)
|
||||||
#if XtSpecificationRelease >= 6
|
#if XtSpecificationRelease >= 6
|
||||||
#define X11_HANGUP_SIGNAL
|
#define X11_HANGUP_SIGNAL
|
||||||
@@ -148,6 +150,7 @@ static void FDECL(nhFreePixel, (XtAppContext, XrmValuePtr, XtPointer,
|
|||||||
static boolean FDECL(new_resource_macro, (String, unsigned));
|
static boolean FDECL(new_resource_macro, (String, unsigned));
|
||||||
static void NDECL(load_default_resources);
|
static void NDECL(load_default_resources);
|
||||||
static void NDECL(release_default_resources);
|
static void NDECL(release_default_resources);
|
||||||
|
static int FDECL(panic_on_error, (Display *, XErrorEvent *));
|
||||||
#ifdef X11_HANGUP_SIGNAL
|
#ifdef X11_HANGUP_SIGNAL
|
||||||
static void FDECL(X11_sig, (int));
|
static void FDECL(X11_sig, (int));
|
||||||
static void FDECL(X11_sig_cb, (XtPointer, XtSignalId *));
|
static void FDECL(X11_sig_cb, (XtPointer, XtSignalId *));
|
||||||
@@ -1273,6 +1276,21 @@ static XtResource resources[] = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
panic_on_error(display, error)
|
||||||
|
Display *display;
|
||||||
|
XErrorEvent *error;
|
||||||
|
{
|
||||||
|
char buf[BUFSZ];
|
||||||
|
XGetErrorText(display, error->error_code, buf, BUFSZ);
|
||||||
|
fprintf(stderr, "X Error: code %i (%s), request %i, minor %i, serial %lu\n",
|
||||||
|
error->error_code, buf,
|
||||||
|
error->request_code, error->minor_code,
|
||||||
|
error->serial);
|
||||||
|
panic("X Error");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
X11_init_nhwindows(argcp, argv)
|
X11_init_nhwindows(argcp, argv)
|
||||||
int *argcp;
|
int *argcp;
|
||||||
@@ -1318,6 +1336,8 @@ char **argv;
|
|||||||
|
|
||||||
/* We don't need to realize the top level widget. */
|
/* We don't need to realize the top level widget. */
|
||||||
|
|
||||||
|
old_error_handler = XSetErrorHandler(panic_on_error);
|
||||||
|
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
/* add new color converter to deal with overused colormaps */
|
/* add new color converter to deal with overused colormaps */
|
||||||
XtSetTypeConverter(XtRString, XtRPixel, nhCvtStringToPixel,
|
XtSetTypeConverter(XtRString, XtRPixel, nhCvtStringToPixel,
|
||||||
|
|||||||
Reference in New Issue
Block a user