summaryrefslogtreecommitdiff
path: root/src/cairo-device.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-06 17:03:56 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-06 17:07:02 +0100
commit91dfee420c3e9d85e5cd4f2cec6dc708c0e471a2 (patch)
treee9e6d4d8f1d9f388d35ca31dd8b83099a4669dd8 /src/cairo-device.c
parent2658d7ef5f8f7e06929f4b1cae64e5312db24ec4 (diff)
device: Reorder finalization so that user data is destroyed last.
As the user is likely to attach the underlying resources to the device for automatic collection upon finalization, it is important that the user data is then destroy last (so that those resources are still available in the surface and device cleanup routines).
Diffstat (limited to 'src/cairo-device.c')
-rw-r--r--src/cairo-device.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cairo-device.c b/src/cairo-device.c
index 1e5bf0f1..f8a499e3 100644
--- a/src/cairo-device.c
+++ b/src/cairo-device.c
@@ -182,6 +182,8 @@ slim_hidden_def (cairo_device_finish);
void
cairo_device_destroy (cairo_device_t *device)
{
+ cairo_user_data_array_t user_data;
+
if (device == NULL ||
CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count))
{
@@ -194,12 +196,15 @@ cairo_device_destroy (cairo_device_t *device)
cairo_device_finish (device);
- _cairo_user_data_array_fini (&device->user_data);
-
assert (device->mutex_depth == 0);
CAIRO_MUTEX_FINI (device->mutex);
+ user_data = device->user_data;
+
device->backend->destroy (device);
+
+ _cairo_user_data_array_fini (&user_data);
+
}
slim_hidden_def (cairo_device_destroy);