diff --git a/lib/include/elements/support/pixmap.hpp b/lib/include/elements/support/pixmap.hpp index b5510892a..9fc7c08ae 100644 --- a/lib/include/elements/support/pixmap.hpp +++ b/lib/include/elements/support/pixmap.hpp @@ -96,8 +96,7 @@ namespace cycfi { namespace elements { if (this != &rhs) { - _surface = rhs._surface; - rhs._surface = nullptr; + std::swap(_surface, rhs._surface); } return *this; } diff --git a/lib/src/support/glyphs.cpp b/lib/src/support/glyphs.cpp index 754108665..18a3b2225 100644 --- a/lib/src/support/glyphs.cpp +++ b/lib/src/support/glyphs.cpp @@ -181,6 +181,13 @@ namespace cycfi { namespace elements { if (&rhs != this) { + if (_glyphs) + cairo_glyph_free(_glyphs); + if (_clusters) + cairo_text_cluster_free(_clusters); + if (_scaled_font) + cairo_scaled_font_destroy(_scaled_font); + _first = rhs._first; _last = rhs._last; _scaled_font = rhs._scaled_font;