[gnome-settings-daemon] media-keys: Avoid leaking grabbed bindings
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] media-keys: Avoid leaking grabbed bindings
- Date: Tue, 14 Feb 2017 15:08:14 +0000 (UTC)
commit 61be0fa38fb802422a3c2408b3e65d7832d28c7d
Author: Rui Matos <tiagomatos gmail com>
Date: Mon Feb 13 21:48:53 2017 +0100
media-keys: Avoid leaking grabbed bindings
If a binding definition changes again before we get the dbus reply for
the previous change we'd never ungrab the previous accel id.
https://bugzilla.gnome.org/show_bug.cgi?id=758302
plugins/media-keys/gsd-media-keys-manager.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 58021d1..6b3428a 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -138,6 +138,7 @@ typedef struct {
char *custom_path;
char *custom_command;
guint accel_id;
+ gboolean ungrab_requested;
} MediaKey;
typedef struct {
@@ -475,6 +476,7 @@ grab_accelerator_complete (GObject *object,
{
GrabData *data = user_data;
MediaKey *key = data->key;
+ GsdMediaKeysManager *manager = data->manager;
GError *error = NULL;
if (!shell_key_grabber_call_grab_accelerator_finish (SHELL_KEY_GRABBER (object),
@@ -484,6 +486,9 @@ grab_accelerator_complete (GObject *object,
g_error_free (error);
}
+ if (key->ungrab_requested)
+ ungrab_media_key (key, manager);
+
media_key_unref (key);
g_slice_free (GrabData, data);
}
@@ -495,8 +500,6 @@ grab_media_key (MediaKey *key,
GrabData *data;
char *tmp;
- ungrab_media_key (key, manager);
-
tmp = get_key_string (manager, key);
data = g_slice_new0 (GrabData);
@@ -531,8 +534,10 @@ static void
ungrab_media_key (MediaKey *key,
GsdMediaKeysManager *manager)
{
- if (key->accel_id == 0)
- return;
+ if (key->accel_id == 0) {
+ key->ungrab_requested = TRUE;
+ return;
+ }
shell_key_grabber_call_ungrab_accelerator (manager->priv->key_grabber,
key->accel_id,
@@ -578,6 +583,7 @@ gsettings_changed_cb (GSettings *settings,
if (key->settings_key == NULL)
continue;
if (strcmp (settings_key, key->settings_key) == 0) {
+ ungrab_media_key (key, manager);
grab_media_key (key, manager);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]