[cairo] UserFontFace vs FtFontFace management (cairomm)
Jonathon Jongsma
jonathon at quotidian.org
Mon Dec 8 06:34:53 PST 2008
Anne et Damien Carbonne wrote:
> Jonathon Jongsma a écrit :
>> In the current cairomm implementation, the lifetime of the wrapper
>> object is managed by the smart pointer that it is created with. When
>> the wrapper object is deleted, the destructor simply calls
>> cairo_font_face_destroy() on the wrapped object. If I were to store
>> an owning reference to the wrapper inside of the wrapped C object, the
>> wrapper's destructor would never be called, so we'd never _destroy()
>> the underlying font face, and it seems that we'd have circular
>> reference issues. Or am I missing something? (quite possible, I admit)
>>
>>
> In the Ada solution I explained in another mail, the "Ada handle" never
> destroys the "Ada object" itself.
> The "Ada handle" only calls ref and unref.
> It is cairo that calls destroy on the attached user data when the ref
> count is 0.
> Then, I destroy the Ada create object(s).
> If I'm correct, there is no cycle here.
> I think this is applicable to C++: Replace "Ada handle" by "C++ smart
> pointer" and "Ada object" by "C++ wrapper".
Yes, thank you. This does seem like the proper way to do things, and I spent this weekend
redesigning things to work this way. With those changes, things work just as you would
expect them to (e.g. Ian's issue with needing to keep a reference to the UserFontFace
object no longer exists). However, I have not pushed this out, because the changes are
quite invasive, and it would mean that we'd essentially be breaking the API/ABI of
cairomm, which is obviously a big deal for projects using cairomm. So I'm still thinking
about the proper way to proceed...
--
jonner
More information about the cairo
mailing list