qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alberto Garcia <berto@igalia.com>,
	Cole Robinson <crobinso@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL v2 17/17] gtk: don't leak the GtkBorder with VTE 0.36
Date: Fri, 13 May 2016 14:32:57 +0200	[thread overview]
Message-ID: <1463142777-13040-18-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1463142777-13040-1-git-send-email-kraxel@redhat.com>

From: Alberto Garcia <berto@igalia.com>

When gtk_widget_style_get() is used to get the "inner-border" style
property, it returns a copy of the GtkBorder which must be freed by
the caller.

This patch also fixes a warning about the unused 'padding' structure
with VTE 0.36.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 1463127654-5171-1-git-send-email-berto@igalia.com
Cc: Cole Robinson <crobinso@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

[ kraxel: adapted to changes in ui patch queue ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index a7d8a8b..7572cec 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -329,17 +329,22 @@ static void gd_update_geometry_hints(VirtualConsole *vc)
 #if defined(CONFIG_VTE)
     } else if (vc->type == GD_VC_VTE) {
         VteTerminal *term = VTE_TERMINAL(vc->vte.terminal);
-        GtkBorder *ib;
+        GtkBorder padding = { 0 };
 
 #if VTE_CHECK_VERSION(0, 37, 0)
-        GtkBorder padding;
         gtk_style_context_get_padding(
                 gtk_widget_get_style_context(vc->vte.terminal),
                 gtk_widget_get_state_flags(vc->vte.terminal),
                 &padding);
-        ib = &padding;
 #else
-        gtk_widget_style_get(vc->vte.terminal, "inner-border", &ib, NULL);
+        {
+            GtkBorder *ib = NULL;
+            gtk_widget_style_get(vc->vte.terminal, "inner-border", &ib, NULL);
+            if (ib) {
+                padding = *ib;
+                gtk_border_free(ib);
+            }
+        }
 #endif
 
         geo.width_inc  = vte_terminal_get_char_width(term);
@@ -352,12 +357,10 @@ static void gd_update_geometry_hints(VirtualConsole *vc)
         geo.min_height = geo.height_inc * VC_TERM_Y_MIN;
         mask |= GDK_HINT_MIN_SIZE;
 
-        if (ib) {
-            geo.base_width  += ib->left + ib->right;
-            geo.base_height += ib->top + ib->bottom;
-            geo.min_width   += ib->left + ib->right;
-            geo.min_height  += ib->top + ib->bottom;
-        }
+        geo.base_width  += padding.left + padding.right;
+        geo.base_height += padding.top + padding.bottom;
+        geo.min_width   += padding.left + padding.right;
+        geo.min_height  += padding.top + padding.bottom;
         geo_widget = vc->vte.terminal;
 #endif
     }
-- 
1.8.3.1

  parent reply	other threads:[~2016-05-13 12:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 12:32 [Qemu-devel] [PULL v2 00/17] ui patch queue Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 01/17] ui: gtk: fix crash when terminal inner-border is NULL Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 02/17] ui: sdl2: Release grab before opening console window Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 03/17] configure: build SDL if only SDL2 available Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 04/17] configure: error on unknown --with-sdlabi value Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 05/17] configure: add echo_version helper Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 06/17] configure: report GTK version Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 07/17] configure: report SDL version Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 08/17] configure: support vte-2.91 Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 09/17] ui: gtk: Fix a runtime warning on vte >= 0.37 Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 10/17] ui: gtk: Fix some deprecation warnings Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 11/17] ui/gtk: copy to clipboard support Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 12/17] spice/gl: add & use qemu_spice_gl_monitor_config Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 13/17] Changed malloc to g_malloc, free to g_free in ui/shader.c Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 14/17] egl-helpers: fix possible resource leak Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 15/17] spice: fix coverity complains Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 16/17] gtk: update grab code for gtk 3.20 Gerd Hoffmann
2016-05-20  7:55   ` Paolo Bonzini
2016-05-13 12:32 ` Gerd Hoffmann [this message]
2016-05-13 14:39 ` [Qemu-devel] [PULL v2 00/17] ui patch queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463142777-13040-18-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=berto@igalia.com \
    --cc=crobinso@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).