summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2022-01-28 11:26:20 +0100
committerraveit65 <[email protected]>2023-04-16 17:55:08 +0200
commitec4b95db16a8728b4c972bf4045a286b7f041498 (patch)
treebacb8e5f4b5c7876e4cbb24bac12f194d02f050b
parent27ba0c85ae8284a8edfdbf8cda52e99100b7185b (diff)
downloadlibmatekbd-ec4b95db16a8728b4c972bf4045a286b7f041498.tar.bz2
libmatekbd-ec4b95db16a8728b4c972bf4045a286b7f041498.tar.xz
matekbd-keyboard-drawing: fix memory leak
-rw-r--r--libmatekbd/matekbd-keyboard-drawing.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libmatekbd/matekbd-keyboard-drawing.c b/libmatekbd/matekbd-keyboard-drawing.c
index 053eded..8b99f85 100644
--- a/libmatekbd/matekbd-keyboard-drawing.c
+++ b/libmatekbd/matekbd-keyboard-drawing.c
@@ -1623,16 +1623,15 @@ alloc_render_context (MatekbdKeyboardDrawing * drawing)
GtkStyleContext *style_context =
gtk_widget_get_style_context (GTK_WIDGET (drawing));
- PangoFontDescription *fd = NULL;
gtk_style_context_get (style_context,
gtk_style_context_get_state (style_context),
- GTK_STYLE_PROPERTY_FONT, &fd, NULL);
+ GTK_STYLE_PROPERTY_FONT, &context->font_desc,
+ NULL);
context->layout = pango_layout_new (pangoContext);
pango_layout_set_ellipsize (context->layout, PANGO_ELLIPSIZE_END);
- context->font_desc = pango_font_description_copy (fd);
context->angle = 0;
context->scale_numerator = 1;
context->scale_denominator = 1;
@@ -2439,7 +2438,7 @@ matekbd_keyboard_drawing_render (MatekbdKeyboardDrawing * kbdrawing,
GtkStyleContext *style_context =
gtk_widget_get_style_context (GTK_WIDGET (kbdrawing));
GdkRGBA dark_color;
- PangoFontDescription *fd = NULL;
+ PangoFontDescription *fd;
gtk_style_context_get_background_color (style_context,
gtk_style_context_get_state (style_context),
@@ -2451,21 +2450,25 @@ matekbd_keyboard_drawing_render (MatekbdKeyboardDrawing * kbdrawing,
gtk_style_context_get (style_context,
gtk_style_context_get_state (style_context),
- GTK_STYLE_PROPERTY_FONT, &fd, NULL);
- fd = pango_font_description_copy (fd);
+ GTK_STYLE_PROPERTY_FONT, &fd,
+ NULL);
MatekbdKeyboardDrawingRenderContext context = {
cr,
kbdrawing->renderContext->angle,
layout,
- pango_font_description_copy (fd),
+ fd,
1, 1,
dark_color
};
if (!context_setup_scaling (&context, kbdrawing, width, height,
dpi_x, dpi_y))
+ {
+ pango_font_description_free (fd);
return FALSE;
+ }
+
cairo_translate (cr, x, y);
draw_keyboard_to_context (&context, kbdrawing);