From 2b76ec2d467ff3cf1f23431729ed3a8887cdfcdb Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 13 Nov 2004 19:46:18 +0000 Subject: [PATCH] Unconditionally destroy the old font, (otherwise, if the same font was selected twice in a row, a reference was lost to it, leading to assertion failures). --- ChangeLog | 7 +++++++ src/cairo-gstate.c | 15 ++++----------- src/cairo_gstate.c | 15 ++++----------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index df10858b3..719e2b74b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-13 Carl Worth + + * src/cairo_gstate.c (_cairo_gstate_select_font): Unconditionally + destroy the old font, (otherwise, if the same font was selected + twice in a row, a reference was lost to it, leading to assertion + failures). + 2004-11-12 Stuart Parmenter * src/cairo_gdip_font.cpp: * src/cairo_gdip_surface.cpp: Added GDI+ backend to Cairo. diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index 21481a66a..04dd92ec3 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1992,21 +1992,14 @@ _cairo_gstate_select_font (cairo_gstate_t *gstate, cairo_font_slant_t slant, cairo_font_weight_t weight) { - cairo_unscaled_font_t *tmp; + _cairo_unscaled_font_destroy (gstate->font); - tmp = _cairo_unscaled_font_create (family, slant, weight); + gstate->font = _cairo_unscaled_font_create (family, slant, weight); - if (tmp == NULL) + if (gstate->font == NULL) return CAIRO_STATUS_NO_MEMORY; - if (gstate->font != tmp) - { - if (gstate->font != NULL) - _cairo_unscaled_font_destroy (gstate->font); - - cairo_matrix_set_identity (&gstate->font_matrix); - gstate->font = tmp; - } + cairo_matrix_set_identity (&gstate->font_matrix); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo_gstate.c b/src/cairo_gstate.c index 21481a66a..04dd92ec3 100644 --- a/src/cairo_gstate.c +++ b/src/cairo_gstate.c @@ -1992,21 +1992,14 @@ _cairo_gstate_select_font (cairo_gstate_t *gstate, cairo_font_slant_t slant, cairo_font_weight_t weight) { - cairo_unscaled_font_t *tmp; + _cairo_unscaled_font_destroy (gstate->font); - tmp = _cairo_unscaled_font_create (family, slant, weight); + gstate->font = _cairo_unscaled_font_create (family, slant, weight); - if (tmp == NULL) + if (gstate->font == NULL) return CAIRO_STATUS_NO_MEMORY; - if (gstate->font != tmp) - { - if (gstate->font != NULL) - _cairo_unscaled_font_destroy (gstate->font); - - cairo_matrix_set_identity (&gstate->font_matrix); - gstate->font = tmp; - } + cairo_matrix_set_identity (&gstate->font_matrix); return CAIRO_STATUS_SUCCESS; }