mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 05:00:17 +01:00
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).
This commit is contained in:
parent
2658d7ef5f
commit
91dfee420c
2 changed files with 9 additions and 4 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -592,11 +592,11 @@ cairo_surface_destroy (cairo_surface_t *surface)
|
|||
/* paranoid check that nobody took a reference whilst finishing */
|
||||
assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count));
|
||||
|
||||
cairo_device_destroy (surface->device);
|
||||
|
||||
_cairo_user_data_array_fini (&surface->user_data);
|
||||
_cairo_user_data_array_fini (&surface->mime_data);
|
||||
|
||||
cairo_device_destroy (surface->device);
|
||||
|
||||
free (surface);
|
||||
}
|
||||
slim_hidden_def(cairo_surface_destroy);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue