[PATCH] ui/gtk: Work around the gtk-menu-bar-accel leak

Akihiko Odaki posted 1 patch 1 week, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260913-gtk-v1-1-3e4ac542e054@rsg.ci.i.u-tokyo.ac.jp
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/gtk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ui/gtk: Work around the gtk-menu-bar-accel leak
Posted by Akihiko Odaki 1 week, 6 days ago
The implementation of the gtk-menu-bar-accel property had a bug that
leaks memory when the set value is an empty string, which was fixed
with:
https://gitlab.gnome.org/GNOME/gtk/-/commit/44bf10c4a2a0463891884a105fa27cf36b73f119

To work around the issue for old GTK versions, replace the empty string
with NULL, which has the same meaning for the property.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
 ui/gtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index c615d35451b6..ae28f1fbb89b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2645,7 +2645,7 @@ static void gd_create_menus(GtkDisplayState *s, DisplayOptions *opts)
 
     /* Disable the default "F10" menu shortcut. */
     settings = gtk_widget_get_settings(s->window);
-    g_object_set(G_OBJECT(settings), "gtk-menu-bar-accel", "", NULL);
+    g_object_set(G_OBJECT(settings), "gtk-menu-bar-accel", NULL, NULL);
 }
 
 

---
base-commit: 209b2afaface001c7d4d981e38f186afe7b24a50
change-id: 20260912-gtk-2ab3b3ab846e

Best regards,
--  
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Re: [PATCH] ui/gtk: Work around the gtk-menu-bar-accel leak
Posted by Marc-André Lureau 1 week, 6 days ago
Hi

On Sun, Sep 13, 2026 at 10:45 AM Akihiko Odaki
<odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
>
> The implementation of the gtk-menu-bar-accel property had a bug that
> leaks memory when the set value is an empty string, which was fixed
> with:
> https://gitlab.gnome.org/GNOME/gtk/-/commit/44bf10c4a2a0463891884a105fa27cf36b73f119
>
> To work around the issue for old GTK versions, replace the empty string
> with NULL, which has the same meaning for the property.
>
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

good catch :)
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  ui/gtk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ui/gtk.c b/ui/gtk.c
> index c615d35451b6..ae28f1fbb89b 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -2645,7 +2645,7 @@ static void gd_create_menus(GtkDisplayState *s, DisplayOptions *opts)
>
>      /* Disable the default "F10" menu shortcut. */
>      settings = gtk_widget_get_settings(s->window);
> -    g_object_set(G_OBJECT(settings), "gtk-menu-bar-accel", "", NULL);
> +    g_object_set(G_OBJECT(settings), "gtk-menu-bar-accel", NULL, NULL);
>  }
>
>
>
> ---
> base-commit: 209b2afaface001c7d4d981e38f186afe7b24a50
> change-id: 20260912-gtk-2ab3b3ab846e
>
> Best regards,
> --
> Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>