diff --git a/awesome.c b/awesome.c index 2ed9bbd21..dcc8c2077 100644 --- a/awesome.c +++ b/awesome.c @@ -249,21 +249,19 @@ xerror(void *data __attribute__ ((unused)), xcb_connection_t *c __attribute__ ((unused)), xcb_generic_error_t *e) { - xutil_error_t *err = xutil_error_get(e); - if(!err) + xutil_error_t err; + + if(!xutil_error_init(e, &err)) return 0; + /* ignore this */ if(e->error_code == XUTIL_BAD_WINDOW - || (e->error_code == XUTIL_BAD_MATCH && err->request_code == XCB_SET_INPUT_FOCUS) - || (e->error_code == XUTIL_BAD_VALUE && err->request_code == XCB_KILL_CLIENT) - || (err->request_code == XCB_CONFIGURE_WINDOW && e->error_code == XUTIL_BAD_MATCH)) - { - xutil_error_delete(err); - return 0; - } + || (e->error_code == XUTIL_BAD_MATCH && err.request_code == XCB_SET_INPUT_FOCUS) + || (e->error_code == XUTIL_BAD_VALUE && err.request_code == XCB_KILL_CLIENT) + || (err.request_code == XCB_CONFIGURE_WINDOW && e->error_code == XUTIL_BAD_MATCH)) + goto bailout; - warn("fatal error: request=%s, error=%s", err->request_label, err->error_label); - xutil_error_delete(err); + warn("X error: request=%s, error=%s", err.request_label, err.error_label); /* * Xlib code was using default X error handler, namely @@ -274,8 +272,10 @@ xerror(void *data __attribute__ ((unused)), * \todo display more informations about the error (like the Xlib default error handler) */ if(e->error_code == XUTIL_BAD_IMPLEMENTATION) - exit(EXIT_FAILURE); + fatal("X error: request=%s, error=%s", err.request_label, err.error_label); + bailout: + xutil_error_wipe(&err); return 0; } diff --git a/common/xutil.c b/common/xutil.c index 9aaf2b8a3..e8028249a 100644 --- a/common/xutil.c +++ b/common/xutil.c @@ -299,14 +299,12 @@ xutil_label_request[] = "NoOperation", }; -xutil_error_t * -xutil_error_get(const xcb_generic_error_t *e) +bool +xutil_error_init(const xcb_generic_error_t *e, xutil_error_t *err) { if(e->response_type != 0) /* This is not an error, this _should_ not happen */ - return NULL; - - xutil_error_t *err = p_new(xutil_error_t, 1); + return false; /* * Get the request code, taken from 'xcb-util/wm'. I can't figure @@ -329,7 +327,7 @@ xutil_error_get(const xcb_generic_error_t *e) else err->error_label = a_strdup(xutil_label_error[e->error_code]); - return err; + return true; } /** Link a name to a key symbol */ diff --git a/common/xutil.h b/common/xutil.h index e9e6e9601..46640e977 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -111,17 +111,16 @@ typedef struct char *error_label; } xutil_error_t; -xutil_error_t *xutil_error_get(const xcb_generic_error_t *); +bool xutil_error_init(const xcb_generic_error_t *, xutil_error_t *); xcb_keysym_t xutil_key_mask_fromstr(const char *); unsigned int xutil_button_fromint(int); xcb_cursor_t xutil_cursor_new(xcb_connection_t *, unsigned int); static inline void -xutil_error_delete(xutil_error_t *err) +xutil_error_wipe(xutil_error_t *err) { p_delete(&err->error_label); p_delete(&err->request_label); - p_delete(&err); } /* Get the informations about the screen.