summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-04-23 22:22:28 +0200
committerBenjamin Otte <otte@redhat.com>2010-04-23 22:22:28 +0200
commit1687c7b7d3074de8eeea1a5c339df9a12cc38da2 (patch)
tree807fec268a8495e37c5f6a1bd9cf8514ad10af12
parent637564c562de21c17c36d192d3ab1b3fe069754b (diff)
xlib: Fix display closing to work properly
Previously we free()'d the cairo_device's memory which was not good at all. Now the code causes cairo_device_finish() instead.
-rw-r--r--src/cairo-xlib-display.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index 6dd62cc6..0b6fbebb 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -108,6 +108,14 @@ _cairo_xlib_display_discard_screens (cairo_xlib_display_t *display)
}
static void
+_cairo_xlib_display_finish (void *abstract_display)
+{
+ cairo_xlib_display_t *display = abstract_display;
+
+ display->display = NULL;
+}
+
+static void
_cairo_xlib_display_destroy (void *abstract_display)
{
cairo_xlib_display_t *display = abstract_display;
@@ -201,22 +209,23 @@ _cairo_xlib_close_display (Display *dpy, XExtCodes *codes)
if (display == NULL)
return 0;
- /* protect the notifies from triggering XErrors */
- XSync (dpy, False);
- old_handler = XSetErrorHandler (_noop_error_handler);
+ if (! cairo_device_acquire (&display->base)) {
+ /* protect the notifies from triggering XErrors */
+ XSync (dpy, False);
+ old_handler = XSetErrorHandler (_noop_error_handler);
- if (cairo_device_acquire (&display->base)) {
- _cairo_xlib_display_notify (display);
- _cairo_xlib_call_close_display_hooks (display);
- _cairo_xlib_display_discard_screens (display);
+ _cairo_xlib_display_notify (display);
+ _cairo_xlib_call_close_display_hooks (display);
+ _cairo_xlib_display_discard_screens (display);
- /* catch any that arrived before marking the display as closed */
- _cairo_xlib_display_notify (display);
- cairo_device_release (&display->base);
- }
+ /* catch any that arrived before marking the display as closed */
+ _cairo_xlib_display_notify (display);
- XSync (dpy, False);
- XSetErrorHandler (old_handler);
+ XSync (dpy, False);
+ XSetErrorHandler (old_handler);
+
+ cairo_device_release (&display->base);
+ }
/*
* Unhook from the global list
@@ -250,7 +259,7 @@ static const cairo_device_backend_t _cairo_xlib_device_backend = {
NULL,
NULL, /* flush */
- NULL, /* finish */
+ _cairo_xlib_display_finish,
_cairo_xlib_display_destroy,
};