diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | cairomm/scaledfont.cc | 8 | ||||
-rw-r--r-- | cairomm/scaledfont.h | 2 |
3 files changed, 19 insertions, 1 deletions
@@ -1,3 +1,13 @@ +2008-12-05 Jonathon Jongsma <jonathon@quotidian.org> + + * cairomm/scaledfont.cc: Fix an error in ScaledFont::get_font_face() where + we were releasing a reference we didn't hold. + Also fix a rather severe memory leak where we weren't calling + cairo_scaled_font_destroy in the ScaledFont destructor. I added a virtual + destructor to ScaledFont, which theoretically changes ABI, but I don't see how + anybody could be using ScaledFont in cairomm currently without serious memory + leaks, so I think it's worthwhile to make this change + 2008-11-14 Jonathon Jongsma <jonathon@quotidian.org> * cairomm/win32_surface.cc: diff --git a/cairomm/scaledfont.cc b/cairomm/scaledfont.cc index 9f890ca..3d1a5d9 100644 --- a/cairomm/scaledfont.cc +++ b/cairomm/scaledfont.cc @@ -42,6 +42,12 @@ ScaledFont::ScaledFont(const RefPtr<FontFace>& font_face, const Matrix& font_mat check_object_status_and_throw_exception(*this); } +ScaledFont::~ScaledFont() +{ + if (cobj()) + cairo_scaled_font_destroy(cobj()); +} + RefPtr<ScaledFont> ScaledFont::create(const RefPtr<FontFace>& font_face, const Matrix& font_matrix, const Matrix& ctm, const FontOptions& options) { @@ -81,7 +87,7 @@ RefPtr<FontFace> ScaledFont::get_font_face() const { cairo_font_face_t* face = cairo_scaled_font_get_font_face(m_cobject); check_object_status_and_throw_exception(*this); - return RefPtr<FontFace>(new FontFace(face, true)); + return RefPtr<FontFace>(new FontFace(face, true /* returned face doesn't have a reference */)); } void ScaledFont::get_font_options(FontOptions& options) const diff --git a/cairomm/scaledfont.h b/cairomm/scaledfont.h index 87b433b..c3e9b8d 100644 --- a/cairomm/scaledfont.h +++ b/cairomm/scaledfont.h @@ -65,6 +65,8 @@ public: */ explicit ScaledFont(cobject* cobj, bool has_reference = false); + virtual ~ScaledFont(); + /** Creates a ScaledFont object from a font face and matrices that describe * the size of the font and the environment in which it will be used. * |