mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 15:48:00 +02:00
[xlib] Propagate real status from get_display()
Avoid throwing away the error and inventing a new NO_MEMORY error for _cairo_xlib_display_get().
This commit is contained in:
parent
2555f83b11
commit
e25b106e9c
3 changed files with 18 additions and 13 deletions
|
|
@ -208,13 +208,15 @@ _cairo_xlib_close_display (Display *dpy, XExtCodes *codes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
cairo_xlib_display_t *
|
||||
_cairo_xlib_display_get (Display *dpy)
|
||||
cairo_status_t
|
||||
_cairo_xlib_display_get (Display *dpy,
|
||||
cairo_xlib_display_t **out)
|
||||
{
|
||||
cairo_xlib_display_t *display;
|
||||
cairo_xlib_display_t **prev;
|
||||
XExtCodes *codes;
|
||||
int render_major, render_minor;
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* There is an apparent deadlock between this mutex and the
|
||||
* mutex for the display, but it's actually safe. For the
|
||||
|
|
@ -247,7 +249,7 @@ _cairo_xlib_display_get (Display *dpy)
|
|||
|
||||
display = malloc (sizeof (cairo_xlib_display_t));
|
||||
if (display == NULL) {
|
||||
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto UNLOCK;
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +263,7 @@ _cairo_xlib_display_get (Display *dpy)
|
|||
|
||||
codes = XAddExtension (dpy);
|
||||
if (codes == NULL) {
|
||||
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
free (display);
|
||||
display = NULL;
|
||||
goto UNLOCK;
|
||||
|
|
@ -316,7 +318,8 @@ _cairo_xlib_display_get (Display *dpy)
|
|||
|
||||
UNLOCK:
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_xlib_display_mutex);
|
||||
return display;
|
||||
*out = display;
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ struct _cairo_xlib_screen_info {
|
|||
cairo_array_t visuals;
|
||||
};
|
||||
|
||||
cairo_private cairo_xlib_display_t *
|
||||
_cairo_xlib_display_get (Display *display);
|
||||
cairo_private cairo_status_t
|
||||
_cairo_xlib_display_get (Display *display, cairo_xlib_display_t **out);
|
||||
|
||||
cairo_private cairo_xlib_display_t *
|
||||
_cairo_xlib_display_reference (cairo_xlib_display_t *info);
|
||||
|
|
|
|||
|
|
@ -2510,6 +2510,7 @@ _cairo_xlib_surface_create_internal (Display *dpy,
|
|||
cairo_xlib_surface_t *surface;
|
||||
cairo_xlib_display_t *display;
|
||||
cairo_xlib_screen_info_t *screen_info;
|
||||
cairo_status_t status;
|
||||
|
||||
CAIRO_MUTEX_INITIALIZE ();
|
||||
|
||||
|
|
@ -2540,9 +2541,9 @@ _cairo_xlib_surface_create_internal (Display *dpy,
|
|||
if (depth == 0)
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_VISUAL));
|
||||
|
||||
display = _cairo_xlib_display_get (dpy);
|
||||
if (display == NULL)
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
status = _cairo_xlib_display_get (dpy, &display);
|
||||
if (status)
|
||||
return _cairo_surface_create_in_error (status);
|
||||
|
||||
screen_info = _cairo_xlib_screen_info_get (display, screen);
|
||||
if (screen_info == NULL) {
|
||||
|
|
@ -3139,6 +3140,7 @@ _cairo_xlib_surface_font_init (Display *dpy,
|
|||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_xlib_surface_font_private_t *font_private;
|
||||
cairo_status_t status;
|
||||
int i;
|
||||
|
||||
font_private = malloc (sizeof (cairo_xlib_surface_font_private_t));
|
||||
|
|
@ -3146,10 +3148,10 @@ _cairo_xlib_surface_font_init (Display *dpy,
|
|||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
font_private->scaled_font = scaled_font;
|
||||
font_private->display = _cairo_xlib_display_get (dpy);
|
||||
if (font_private->display == NULL) {
|
||||
status = _cairo_xlib_display_get (dpy, &font_private->display);
|
||||
if (status) {
|
||||
free (font_private);
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* initialize and hook into the CloseDisplay callback */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue