Skip to content

Commit

Permalink
snapshot: Avoid triggering assertion for grabbing the target during d…
Browse files Browse the repository at this point in the history
…estroy

If the source wins the race to acquire the original surface as it is
being destroyed, it triggers an assertion.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Chris Wilson committed May 1, 2012
1 parent f62f8f9 commit 52dfa03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/cairo-surface-inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ _cairo_surface_flush (cairo_surface_t *surface)
return status;
}

static inline cairo_surface_t *
_cairo_surface_reference (cairo_surface_t *surface)
{
if (!CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
_cairo_reference_count_inc (&surface->ref_count);
return surface;
}

#endif /* CAIRO_SURFACE_INLINE_H */
3 changes: 2 additions & 1 deletion src/cairo-surface-snapshot-inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define CAIRO_SURFACE_SNAPSHOT_INLINE_H

#include "cairo-surface-snapshot-private.h"
#include "cairo-surface-inline.h"

static inline cairo_bool_t
_cairo_surface_snapshot_is_reused (cairo_surface_t *surface)
Expand All @@ -51,7 +52,7 @@ _cairo_surface_snapshot_get_target (cairo_surface_t *surface)
cairo_surface_t *target;

CAIRO_MUTEX_LOCK (snapshot->mutex);
target = cairo_surface_reference (snapshot->target);
target = _cairo_surface_reference (snapshot->target);
CAIRO_MUTEX_UNLOCK (snapshot->mutex);

return target;
Expand Down

0 comments on commit 52dfa03

Please sign in to comment.