[test/ft-font-create-for-ft-face] Fix the lifetime issues of FT_Face.

The font_face created from cairo_ft_font_face_create_for_ft_face()
was being kept alive by a reference from the context beyond the
lifetime of the parent cairo_scaled_font_t (which owned the FT_Face).
Correct the example in the test code to remove this errant reference
before cleaning up the fonts. (To be fair, to actually trigger a bug
one has to evict the FT_Face from the cache before using the font_face
- merely creating a cairo_scaled_font_t for every font on the system is
enough.)
This commit is contained in:
Chris Wilson 2008-04-29 09:03:00 +01:00
parent 00965edf49
commit 5d20479b99

View file

@ -50,7 +50,9 @@ draw (cairo_t *cr, int width, int height)
/* We're trying here to get our hands on _some_ FT_Face but we do
* not at all care which one. So we start with an empty pattern
* and do the minimal substitution on it in order to get a valid
* pattern. */
* pattern.
*
* Do not use this in production code! */
pattern = FcPatternCreate ();
if (! pattern) {
cairo_test_log ("FcPatternCreate failed.\n");
@ -117,8 +119,10 @@ draw (cairo_t *cr, int width, int height)
/* Set the font_face and force cairo to actually use it for
* something. */
cairo_save (cr);
cairo_set_font_face (cr, font_face);
cairo_font_extents (cr, &font_extents);
cairo_restore (cr);
/* Finally, even more cleanup */
cairo_font_face_destroy (font_face);