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:34:20 +0200 |
commit | 3d18ca76a597eb8d0e36889190c7438f21ce290f (patch) | |
tree | b7c7b51295a29a6df26f8ccb99028545a1296bec | |
parent | ef9906c76db626b3fd8d4886202336bbcd632ef2 (diff) | |
download | gnome-settings-daemon-3d18ca76a597eb8d0e36889190c7438f21ce290f.tar.gz |
wacom: Fix memory leaks
Several small leaks exist were found and fixed in the wacom plugin after
running valgrind.
-rw-r--r-- | plugins/wacom/gsd-wacom-device.c | 1 | ||||
-rw-r--r-- | plugins/wacom/gsd-wacom-manager.c | 35 |
2 files changed, 34 insertions, 2 deletions
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c index 6a21e50b..f40369bd 100644 --- a/plugins/wacom/gsd-wacom-device.c +++ b/plugins/wacom/gsd-wacom-device.c @@ -1488,6 +1488,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 dd9eaa94..d25a2c14 100644 --- a/plugins/wacom/gsd-wacom-manager.c +++ b/plugins/wacom/gsd-wacom-manager.c @@ -321,6 +321,7 @@ set_area (GsdWacomDevice *device, if (nvalues != 4) { g_error ("Area configuration requires 4 values."); + g_variant_unref (value); return; } @@ -333,6 +334,7 @@ set_area (GsdWacomDevice *device, if (!area) { g_warning ("No default area could be obtained from the device"); + g_variant_unref (value); return; } @@ -352,6 +354,7 @@ set_area (GsdWacomDevice *device, property.data.i[3]); wacom_set_property (device, &property); } + g_variant_unref (value); } static void @@ -366,7 +369,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 @@ -463,9 +465,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); @@ -514,6 +516,10 @@ set_device_buttonmap (GsdWacomDevice *device, int i, j, rc; xdev = open_device (device); + if (xdev == NULL) { + g_variant_unref (value); + return; + } intmap = g_variant_get_fixed_array (value, &nmap, sizeof (gint32)); map = g_new0 (unsigned char, nmap); @@ -783,6 +789,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 @@ -1156,8 +1163,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 |