diff options
author | Jason Gerecke <killertofu@gmail.com> | 2016-07-06 16:07:37 -0700 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2016-08-22 20:16:59 +0200 |
commit | 1b2651e88f932be11fd2dc175aa3de8e242ffc1b (patch) | |
tree | ea2fa9cd577ff5aefe72536b3b45db2c2fb89233 /plugins/wacom | |
parent | 8f021adf8f7327226284705988b98584f5573ed1 (diff) | |
download | gnome-settings-daemon-1b2651e88f932be11fd2dc175aa3de8e242ffc1b.tar.gz |
wacom: Fix memory leaks
Several small leaks exist were found and fixed in the wacom plugin after
running valgrind.
Diffstat (limited to 'plugins/wacom')
-rw-r--r-- | plugins/wacom/gsd-wacom-device.c | 1 | ||||
-rw-r--r-- | plugins/wacom/gsd-wacom-manager.c | 35 |
2 files changed, 33 insertions, 3 deletions
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c index 03567dd2..33d9cc58 100644 --- a/plugins/wacom/gsd-wacom-device.c +++ b/plugins/wacom/gsd-wacom-device.c @@ -1504,6 +1504,7 @@ gsd_wacom_device_constructor (GType type, device->priv->type = WACOM_TYPE_INVALID; goto end; } + libwacom_error_free (&wacom_error); } gsd_wacom_device_update_from_db (device, wacom_device, device->priv->path); diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c index 88adc355..179aa0be 100644 --- a/plugins/wacom/gsd-wacom-manager.c +++ b/plugins/wacom/gsd-wacom-manager.c @@ -323,6 +323,7 @@ set_area (GsdWacomDevice *device, if (nvalues != 4) { g_error ("Area configuration requires 4 values."); + g_variant_unref (value); return; } @@ -335,6 +336,7 @@ set_area (GsdWacomDevice *device, if (!area) { g_warning ("No default area could be obtained from the device"); + g_variant_unref (value); return; } @@ -354,6 +356,7 @@ set_area (GsdWacomDevice *device, property.data.i[3]); wacom_set_property (device, &property); } + g_variant_unref (value); } static void @@ -368,7 +371,6 @@ reset_area (GsdWacomDevice *device) variant = g_variant_new_array (G_VARIANT_TYPE_INT32, values, G_N_ELEMENTS (values)); set_area (device, variant); - g_variant_unref (variant); } static void @@ -467,9 +469,9 @@ set_keep_aspect (GsdWacomDevice *device, */ if (!keep_aspect) { g_settings_set_value (settings, KEY_AREA, variant); - g_variant_unref (variant); return; } + g_variant_unref (variant); /* Reset the device area to get the default area */ reset_area (device); @@ -518,8 +520,10 @@ set_device_buttonmap (GsdWacomDevice *device, int i, j, rc; xdev = open_device (device); - if (xdev == NULL) + if (xdev == NULL) { + g_variant_unref (value); return; + } intmap = g_variant_get_fixed_array (value, &nmap, sizeof (gint32)); map = g_new0 (unsigned char, nmap); @@ -791,6 +795,7 @@ gsettings_oled_changed (GSettings *settings, label = g_settings_get_string (settings, OLED_LABEL); device = g_object_get_data (G_OBJECT (button->settings), "parent-device"); set_oled (device, button->id, label); + g_free (label); } static void @@ -1162,8 +1167,32 @@ static void gsd_wacom_manager_remove_gdk_device (GsdWacomManager *manager, GdkDevice *gdk_device) { + GsdWacomDevice *device; + GSettings *settings; + GsdWacomDeviceType type; + g_debug ("Removing device '%s' from known devices list", gdk_device_get_name (gdk_device)); + + device = g_hash_table_lookup (manager->priv->devices, gdk_device); + type = gsd_wacom_device_get_device_type (device); + settings = gsd_wacom_device_get_settings (device); + + g_signal_handlers_disconnect_by_data (G_OBJECT (settings), device); + + if (type == WACOM_TYPE_STYLUS || type == WACOM_TYPE_ERASER) { + GList *styli, *l; + + styli = gsd_wacom_device_list_styli (device); + + for (l = styli ; l ; l = l->next) { + settings = gsd_wacom_stylus_get_settings (l->data); + g_signal_handlers_disconnect_by_data (G_OBJECT (settings), l->data); + } + + g_list_free (styli); + } + g_hash_table_remove (manager->priv->devices, gdk_device); /* Enable this chunk of code if you want to valgrind |