[gnome-settings-daemon] wacom: make sure to unref GnomeRRConfig and GnomeRROutputInfo



commit 4c21d193f7b349ab26a06e47461210b5cf47e3ff
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Jan 26 15:41:21 2012 -0500

    wacom: make sure to unref GnomeRRConfig and GnomeRROutputInfo
    
    And ensure the output info stays alive even if we unref the config
    before.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668776

 plugins/wacom/gsd-wacom-device.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 548a7b2..b516779 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -417,6 +417,7 @@ find_output_by_edid (const gchar *vendor, const gchar *product, const gchar *ser
 	GnomeRRScreen *rr_screen;
 	GnomeRRConfig *rr_config;
 	GnomeRROutputInfo **rr_output_info;
+        GnomeRROutputInfo *retval = NULL;
 
 	/* TODO: Check the value of 'error' */
 	rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
@@ -445,10 +446,15 @@ find_output_by_edid (const gchar *vendor, const gchar *product, const gchar *ser
 		g_free (o_product);
 		g_free (o_serial);
 
-		if (match)
-			return *rr_output_info;
+		if (match) {
+			retval = g_object_ref (*rr_output_info);
+			break;
+		}
 	}
-	return NULL;
+
+	g_object_unref (rr_config);
+
+	return retval;
 }
 
 static GnomeRROutputInfo*
@@ -597,19 +603,24 @@ gint
 gsd_wacom_device_get_display_monitor (GsdWacomDevice *device)
 {
 	gint area[4];
+	gboolean is_active;
 	GnomeRROutputInfo *rr_output_info;
 
 	rr_output_info = find_output(device);
 	if (rr_output_info == NULL)
 		return -1;
 
-	if (!gnome_rr_output_info_is_active (rr_output_info))
+	is_active = gnome_rr_output_info_is_active (rr_output_info);
+	gnome_rr_output_info_get_geometry (rr_output_info, &area[0], &area[1], &area[2], &area[3]);
+
+	g_object_unref (rr_output_info);
+
+	if (!is_active)
 	{
 		g_warning ("Output is not active.");
 		return -1;
 	}
 
-	gnome_rr_output_info_get_geometry (rr_output_info, &area[0], &area[1], &area[2], &area[3]);
 	if (area[2] <= 0 || area[3] <= 0)
 	{
 		g_warning ("Output has non-positive area.");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]