Index: ChangeLog =================================================================== RCS file: /mirrors/freedesktop/cairo/cairo/ChangeLog,v retrieving revision 1.966 diff -u -p -r1.966 ChangeLog --- ChangeLog 23 Aug 2005 20:34:14 -0000 1.966 +++ ChangeLog 23 Aug 2005 20:38:17 -0000 @@ -1,3 +1,17 @@ +2005-08-23 Carl Worth + + * src/cairo-font.c: (cairo_font_face_reference), + (cairo_font_face_destroy), (cairo_scaled_font_reference), + (cairo_scaled_font_destroy): + * src/cairo-pattern.c: (cairo_pattern_reference), + (cairo_pattern_destroy): + * src/cairo-surface.c: (cairo_surface_reference), + (cairo_surface_destroy): + * src/cairo.c: (cairo_reference), (cairo_destroy): + Detect (by assert and crash) if users attempt to twice destroy or + re-reference a destroyed object. The condition for detecting this + case is a ref_count of 0. + 2005-08-23 Owen Taylor * src/cairo-ft-font.c (_cairo_ft_scaled_font_show_glyphs): Index: src/cairo-font.c =================================================================== RCS file: /mirrors/freedesktop/cairo/cairo/src/cairo-font.c,v retrieving revision 1.73 diff -u -p -r1.73 cairo-font.c --- src/cairo-font.c 23 Aug 2005 03:43:23 -0000 1.73 +++ src/cairo-font.c 23 Aug 2005 20:37:37 -0000 @@ -85,6 +85,8 @@ cairo_font_face_reference (cairo_font_fa if (font_face->ref_count == (unsigned int)-1) return font_face; + assert (font_face->ref_count > 0); + font_face->ref_count++; return font_face; @@ -107,6 +109,8 @@ cairo_font_face_destroy (cairo_font_face if (font_face->ref_count == (unsigned int)-1) return; + assert (font_face->ref_count > 0); + if (--(font_face->ref_count) > 0) return; @@ -760,6 +764,8 @@ cairo_scaled_font_reference (cairo_scale if (scaled_font->ref_count == (unsigned int)-1) return scaled_font; + assert (scaled_font->ref_count > 0); + /* If the original reference count is 0, then this font must have * been found in font_map->holdovers, (which means this caching is * actually working). So now we remove it from the holdovers @@ -807,6 +813,8 @@ cairo_scaled_font_destroy (cairo_scaled_ if (scaled_font->ref_count == (unsigned int)-1) return; + assert (scaled_font->ref_count > 0); + if (--(scaled_font->ref_count) > 0) return; Index: src/cairo-pattern.c =================================================================== RCS file: /mirrors/freedesktop/cairo/cairo/src/cairo-pattern.c,v retrieving revision 1.61 diff -u -p -r1.61 cairo-pattern.c --- src/cairo-pattern.c 23 Aug 2005 03:43:23 -0000 1.61 +++ src/cairo-pattern.c 23 Aug 2005 20:14:22 -0000 @@ -532,6 +532,8 @@ cairo_pattern_reference (cairo_pattern_t if (pattern->ref_count == (unsigned int)-1) return pattern; + assert (pattern->ref_count > 0); + pattern->ref_count++; return pattern; @@ -570,6 +572,8 @@ cairo_pattern_destroy (cairo_pattern_t * if (pattern->ref_count == (unsigned int)-1) return; + assert (pattern->ref_count > 0); + pattern->ref_count--; if (pattern->ref_count) return; Index: src/cairo-surface.c =================================================================== RCS file: /mirrors/freedesktop/cairo/cairo/src/cairo-surface.c,v retrieving revision 1.97 diff -u -p -r1.97 cairo-surface.c --- src/cairo-surface.c 21 Aug 2005 19:13:17 -0000 1.97 +++ src/cairo-surface.c 23 Aug 2005 20:14:56 -0000 @@ -268,6 +268,8 @@ cairo_surface_reference (cairo_surface_t if (surface->ref_count == (unsigned int)-1) return surface; + assert (surface->ref_count > 0); + surface->ref_count++; return surface; @@ -290,6 +292,8 @@ cairo_surface_destroy (cairo_surface_t * if (surface->ref_count == (unsigned int)-1) return; + assert (surface->ref_count > 0); + surface->ref_count--; if (surface->ref_count) return; Index: src/cairo.c =================================================================== RCS file: /mirrors/freedesktop/cairo/cairo/src/cairo.c,v retrieving revision 1.130 diff -u -p -r1.130 cairo.c --- src/cairo.c 23 Aug 2005 07:03:10 -0000 1.130 +++ src/cairo.c 23 Aug 2005 20:15:37 -0000 @@ -222,6 +222,8 @@ cairo_reference (cairo_t *cr) { if (cr->ref_count == (unsigned int)-1) return cr; + + assert (cr->ref_count > 0); cr->ref_count++; @@ -241,6 +243,8 @@ cairo_destroy (cairo_t *cr) { if (cr->ref_count == (unsigned int)-1) return; + + assert (cr->ref_count > 0); cr->ref_count--; if (cr->ref_count)