From bda6dbbecf8627f0696eef974c0bfe5f42727d29 Mon Sep 17 00:00:00 2001 From: "Shawn M. Chapla" Date: Sun, 14 Feb 2021 14:51:06 -0500 Subject: [PATCH] Don't double attach accels on enable window mods Check whether accels are currently attached to a window before attaching them when enabling window modifiers. This commit fixes an assert in _gtk_accel_group_attach introduced by cfcac9fb, which erroneously assumed that is harmless to re-add accel groups that have already been added to a window. Signed-off-by: Shawn M. Chapla --- src/virt-viewer-window.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index aef5874..c3e056b 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -888,15 +888,21 @@ virt_viewer_window_enable_modifiers(VirtViewerWindow *self) GSList *accels; guint i; GtkAccelKey key; + GSList *attached_accels; if (priv->accel_enabled) return; /* This allows F10 activating menu bar */ g_object_set_property(G_OBJECT(settings), "gtk-menu-bar-accel", &priv->accel_setting); + attached_accels = gtk_accel_groups_from_object(G_OBJECT(priv->window)); /* This allows global accelerators like Ctrl+Q == Quit */ for (accels = priv->accel_list ; accels ; accels = accels->next) { + /* Do not attach accels that are already attached. */ + if (attached_accels && g_slist_find(attached_accels, accels->data)) + continue; + gtk_window_add_accel_group(GTK_WINDOW(priv->window), accels->data); }