[gnome-settings-daemon/gnome-3-14] wacom: Fix memory leaks
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-14] wacom: Fix memory leaks
- Date: Mon, 22 Aug 2016 18:37:35 +0000 (UTC)
commit 1bbd85c88635df78830c5448af8836b47f57737c
Author: Jason Gerecke <killertofu gmail com>
Date: Wed Jul 6 16:07:37 2016 -0700
wacom: Fix memory leaks
Several small leaks exist were found and fixed in the wacom plugin after
running valgrind.
plugins/wacom/gsd-wacom-device.c | 1 +
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 5182d7c..ac67482 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -1523,6 +1523,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 c3c4193..b624394 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -301,6 +301,7 @@ set_area (GsdWacomDevice *device,
if (nvalues != 4) {
g_error ("Area configuration requires 4 values.");
+ g_variant_unref (value);
return;
}
@@ -313,6 +314,7 @@ set_area (GsdWacomDevice *device,
if (!area) {
g_warning ("No default area could be obtained from the device");
+ g_variant_unref (value);
return;
}
@@ -332,6 +334,7 @@ set_area (GsdWacomDevice *device,
property.data.i[3]);
wacom_set_property (device, &property);
}
+ g_variant_unref (value);
}
static void
@@ -346,7 +349,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
@@ -441,9 +443,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);
@@ -488,6 +490,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);
@@ -757,6 +763,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
@@ -1091,8 +1098,32 @@ device_removed_cb (GdkDeviceManager *device_manager,
GdkDevice *gdk_device,
GsdWacomManager *manager)
{
+ 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);
gsd_device_mapper_remove_input (manager->priv->device_mapper,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]