[gnome-color-manager] trivial: Ensure we refcount gcm_device_get_profiles() to avoid insanity
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: Ensure we refcount gcm_device_get_profiles() to avoid insanity
- Date: Sat, 12 Jun 2010 08:12:38 +0000 (UTC)
commit bfd528e74823af83c8bb026d3c99e01be684878b
Author: Richard Hughes <richard hughsie com>
Date: Sat Jun 12 09:00:51 2010 +0100
trivial: Ensure we refcount gcm_device_get_profiles() to avoid insanity
src/gcm-client.c | 4 +++-
src/gcm-device.c | 4 ++--
src/gcm-prefs.c | 6 +++++-
src/gcm-self-test.c | 1 +
4 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 25842bf..e215d26 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -1197,8 +1197,10 @@ gcm_client_add_device (GcmClient *client, GcmDevice *device, GError **error)
if (device_tmp != NULL) {
egg_debug ("already exists, copy settings and remove old device: %s", device_id);
array = gcm_device_get_profiles (device_tmp);
- if (array != NULL)
+ if (array != NULL) {
gcm_device_set_profiles (device, array);
+ g_ptr_array_unref (array);
+ }
gcm_device_set_saved (device, gcm_device_get_saved (device_tmp));
ret = gcm_client_remove_device_internal (client, device_tmp, FALSE, error);
if (!ret)
diff --git a/src/gcm-device.c b/src/gcm-device.c
index 3aa951f..60ca19e 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -486,13 +486,13 @@ gcm_device_set_title (GcmDevice *device, const gchar *title)
/**
* gcm_device_get_profiles:
*
- * Return value: the profiles. Do not unref this value
+ * Return value: the profiles. Free with g_ptr_array_unref()
**/
GPtrArray *
gcm_device_get_profiles (GcmDevice *device)
{
g_return_val_if_fail (GCM_IS_DEVICE (device), NULL);
- return device->priv->profiles;
+ return g_ptr_array_ref (device->priv->profiles);
}
/**
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 54a42da..db326dc 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -982,6 +982,8 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
CA_PROP_EVENT_DESCRIPTION, _("Profiling completed"), NULL);
out:
g_free (destination);
+ if (profile_array != NULL)
+ g_ptr_array_unref (profile_array);
if (calibrate != NULL)
g_object_unref (calibrate);
if (file != NULL)
@@ -1669,7 +1671,7 @@ gcm_prefs_devices_treeview_clicked_cb (GtkTreeSelection *selection, gpointer use
const gchar *device_model = NULL;
const gchar *device_manufacturer = NULL;
const gchar *eisa_id = NULL;
- GPtrArray *profiles;
+ GPtrArray *profiles = NULL;
GcmProfile *profile;
/* This will only work in single or browse selection mode! */
@@ -1819,6 +1821,8 @@ gcm_prefs_devices_treeview_clicked_cb (GtkTreeSelection *selection, gpointer use
/* can this device calibrate */
gcm_prefs_set_calibrate_button_sensitivity ();
out:
+ if (profiles != NULL)
+ g_ptr_array_unref (profiles);
g_free (id);
}
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index a4ac4a7..9383963 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -479,6 +479,7 @@ gcm_test_device_func (void)
g_free (icc_filename1);
g_free (icc_filename2);
g_free (contents);
+ g_ptr_array_unref (profiles);
g_object_unref (device);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]