Problem with freeing font faces
Klaus Reimer <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I'm trying to use freetype fonts in cairo and have some problems getting
them released when they are no longer used. I'm note sure if this is a
bug or if I'm doing something wrong (Tried with Cairo 1.12.14 and with
current Git HEAD).
The first thing I do is creating the font face from a freetype font:
cairo_font_face_t* font =
cairo_ft_font_face_create_for_ft_face(face, 0);
Now the reference counter of this font face is 1 as expected. Now I set
this font in the current cairo context:
cairo_set_font_face(cr, font);
The reference counter is now 2. I guess this is correct because now
there is one reference in the current cairo context and I still have my
own reference. So I destroy my own reference to get back to reference
count 1:
cairo_font_face_destroy(font);
Now I draw some text using this font:
cairo_show_text(cr, "Hello World");
After this line of code the reference counter is suddenly at 3. I think
this is pretty strange and it looks like a bug to me.
Finally I remove the font from the cairo context with this line:
cairo_set_font_face(cr, nullptr);
The reference counter drops from 3 to 2. Now there should be no
reference to the font anymore but the font (and its userdata) is not
freed because there are two unknown references left.
When I remove the "cairo_show_text" call from my code, then it works
correctly. The reference counter drops to 0 and the destroy callbacks of
registered userdata is called.
The full C++ source code of my test program can be downloaded here:
http://www.ailis.de/~k/permdata/20140810/cairotest.cc
So what's going on there? Something wrong in my code or a Cairo bug?
--
Klaus Reimer <http://www.ailis.de/~k/>
[2FC4 CCA0 C03B 1E5F 1ACC 94D6 6461 426C E734 75A1]
--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
signature.asc
(application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJT55cCAAoJEGRhQmznNHWhiZAP/28kSP4UHqVu5hpxtHEZf3Vx pbEevyZOUY8Yl7ksBi5ZlxAZCgxUrv/ygX9opJ5M3yvIhVxYxYb9ejdz9Xc+2n6m u2DK+jLtQckFrNqMkqZSJODOK+iTlTAHZDC3o9wpqe02+kyu+DOb7/r/hrOIZwrp Ykkbpst2XzSs4fv02S9+fCDYRwAZH/a5IGSzH+oarxjM/bEfqccgQsWCvS/Tud42 daRzAjzOvuwHoAv2mDQOVdPk8UUDvaatWYv590AxTvYOQ5JbQljkUMsC1gD8ns1R iblsf04kO2revLlWAwZX0LaLQtIi/xSlgmYjZ+fD6q3LdBTEuwgHVbqgof8h8mpm kMVcPA5YHX2J5Nv/ivgwPhJY3R6VxI5tHId03Yf/57pZ5xF2l/I3Q4QsbX6RT6BM /G+pHe9d8qlYIiaSJ6GQOLg1oKKTLlwrpdIIRDe06MMy0amoGMgottNU8TaL3dxV ZbdajVLf0lrmOC/5GBBnbZ3h7V1H+YgTRbY0YNEMWFWP1ONA0Yu7XIimBnzppptE Z6fypradrixygS9ywNjTSATGNhOFbr5C+3iU+wXdmg9B3DnNmn6EPbmIW4/Vr7OU IqdoQtsr1FDqAj7Nr6AfFFl/RVKgYY2lNvd/QOMMR2ZKAdXCLbd+i7W5xzxkkHsj k7a2CIxSTIv3AHM2znRo =JFi0 -----END PGP SIGNATURE-----