mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 07:38:22 +02:00
do not ignore errors when creating styles.
This fixes statuses being ignored when calling
CreateSizedCopyOfStyle. As a side effect, it cleans up
two other bugs - the font object was sometimes not
freed, and a the scaled font mutex was aquired recursively,
causing a hang in the invalid-matrix test.
(cherry picked from commit b6b9cef713)
This commit is contained in:
parent
c00bf48648
commit
f27164c899
1 changed files with 26 additions and 11 deletions
|
|
@ -178,30 +178,35 @@ cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id)
|
|||
return &font_face->base;
|
||||
}
|
||||
|
||||
static ATSUStyle
|
||||
static OSStatus
|
||||
CreateSizedCopyOfStyle(ATSUStyle inStyle,
|
||||
const Fixed *theSize,
|
||||
const CGAffineTransform *theTransform)
|
||||
const CGAffineTransform *theTransform,
|
||||
ATSUStyle *style)
|
||||
{
|
||||
ATSUStyle style;
|
||||
OSStatus err;
|
||||
const ATSUAttributeTag theFontStyleTags[] = { kATSUSizeTag,
|
||||
kATSUFontMatrixTag };
|
||||
kATSUFontMatrixTag };
|
||||
const ByteCount theFontStyleSizes[] = { sizeof(Fixed),
|
||||
sizeof(CGAffineTransform) };
|
||||
sizeof(CGAffineTransform) };
|
||||
ATSUAttributeValuePtr theFontStyleValues[] = { (Fixed *)theSize,
|
||||
(CGAffineTransform *)theTransform };
|
||||
(CGAffineTransform *)theTransform };
|
||||
|
||||
err = ATSUCreateAndCopyStyle(inStyle, &style);
|
||||
err = ATSUCreateAndCopyStyle (inStyle, style);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
err = ATSUSetAttributes(style,
|
||||
err = ATSUSetAttributes(*style,
|
||||
sizeof(theFontStyleTags) /
|
||||
sizeof(ATSUAttributeTag), theFontStyleTags,
|
||||
theFontStyleSizes, theFontStyleValues);
|
||||
if (err != noErr)
|
||||
ATSUDisposeStyle (*style);
|
||||
|
||||
return style;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_atsui_font_set_metrics (cairo_atsui_font_t *font)
|
||||
{
|
||||
|
|
@ -268,7 +273,12 @@ _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
|
|||
0., 0.);
|
||||
font->size = FloatToFixed (xscale);
|
||||
|
||||
font->style = CreateSizedCopyOfStyle (style, &font->size, &font->font_matrix);
|
||||
err = CreateSizedCopyOfStyle (style, &font->size, &font->font_matrix, &font->style);
|
||||
if (err != noErr) {
|
||||
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
status = CAIRO_STATUS_NO_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
{
|
||||
Fixed theSize = FloatToFixed(1.0);
|
||||
|
|
@ -295,7 +305,12 @@ _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
|
|||
|
||||
FAIL:
|
||||
if (status) {
|
||||
cairo_scaled_font_destroy (&font->base);
|
||||
if (font) {
|
||||
if (font->style)
|
||||
ATSUDisposeStyle(font->style);
|
||||
free (font);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue