[evolution-data-server/meego-eds] Handle references of GVariants neatly. Fixes a bunch of wrong assumptions.



commit 0e4ed8d834a9b274b57481154dcd2a70e6c15418
Author: Srinivasa Ragavan <srini linux intel com>
Date:   Thu Jul 7 19:18:16 2011 +0300

    Handle references of GVariants neatly. Fixes a bunch of wrong assumptions.

 mail/daemon/e-mail-data-folder.c |   21 +++++++++++++++++----
 mail/daemon/e-mail-data-store.c  |    3 +++
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/mail/daemon/e-mail-data-folder.c b/mail/daemon/e-mail-data-folder.c
index ad808f8..fb00695 100644
--- a/mail/daemon/e-mail-data-folder.c
+++ b/mail/daemon/e-mail-data-folder.c
@@ -1396,20 +1396,21 @@ variant_from_info (CamelMessageInfoBase *info)
 			g_variant_builder_add (b1, "t", info->references->references[i].id.id);
 		}
 		v1 = g_variant_builder_end (b1);
+		g_object_ref (v1);
 		g_variant_builder_unref (b1);
 	
 		g_variant_builder_add_value (builder, v1);
-		//g_variant_unref (v1);
+		g_variant_unref (v1);
 	} else {
 		g_variant_builder_add (builder, "i", 0);
 		b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
 		g_variant_builder_add (b1, "t", 0);
 		v1 = g_variant_builder_end (b1);
+		g_object_ref (v1);
 		g_variant_builder_unref (b1);
 	
 		g_variant_builder_add_value (builder, v1);
-		
-
+		g_variant_unref (v1);		
 	}
 
 	/* User Flags */
@@ -1421,10 +1422,11 @@ variant_from_info (CamelMessageInfoBase *info)
 	}
 	g_variant_builder_add (b1, "s", "");
 	v1 = g_variant_builder_end (b1);
+	g_object_ref (v1);
 	g_variant_builder_unref (b1);
 	
 	g_variant_builder_add_value (builder, v1);
-
+	g_object_unref (v1);
 	/* User Tags */
 	b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
 	tags = info->user_tags;
@@ -1434,10 +1436,12 @@ variant_from_info (CamelMessageInfoBase *info)
 		g_variant_builder_add (b2, "s", tags->value);
 		
 		v1 = g_variant_builder_end (b2);
+		g_object_ref (v1);
 		g_variant_builder_unref (b2);
 
 		/* FIXME: Should we handle empty tags? Can it be empty? If it potential crasher ahead*/
 		g_variant_builder_add_value (b1, v1);
+		g_variant_unref (v1);		
 
 		tags = tags->next;
 	}
@@ -1446,15 +1450,23 @@ variant_from_info (CamelMessageInfoBase *info)
 	g_variant_builder_add (b2, "s", "");
 	g_variant_builder_add (b2, "s", "");	
 	v1 = g_variant_builder_end (b2);
+	g_object_ref (v1);
+
 	g_variant_builder_unref (b2);
 	g_variant_builder_add_value (b1, v1);
+	g_object_unref (v1);
 
 	v1 = g_variant_builder_end (b1);
+	g_object_ref (v1);
+
 	g_variant_builder_unref (b1);
 	
 	g_variant_builder_add_value (builder, v1);
+	g_object_unref (v1);
 
 	v = g_variant_builder_end (builder);
+	g_object_ref (v);
+
 	g_variant_builder_unref (builder);
 
 	return v;
@@ -1478,6 +1490,7 @@ gmi_done (gboolean success, gpointer sdata, GError *error)
 	variant = variant_from_info (data->info);
 	micro(printf("MessageInfo: %s %p\n", data->info->uid, data->info));
 	egdbus_folder_cf_complete_get_message_info (data->object, data->invocation, variant);
+	g_object_unref (variant);
 
 	camel_message_info_free (data->info);
 	g_free (data->uid);
diff --git a/mail/daemon/e-mail-data-store.c b/mail/daemon/e-mail-data-store.c
index 7c0a5c9..70c9a17 100644
--- a/mail/daemon/e-mail-data-store.c
+++ b/mail/daemon/e-mail-data-store.c
@@ -171,8 +171,10 @@ handle_get_folder_info_cb (CamelStore *store, CamelFolderInfo *info, gpointer da
 	g_variant_builder_add (builder, "(sssuii)", "", "", "", 0, -1, -1);
 	
 	variant = g_variant_builder_end (builder);
+	g_variant_ref (variant);
 	g_variant_builder_unref (builder);
 	
+	micro(printf("%s\n", g_variant_print (variant, TRUE)));
 	egdbus_store_ms_complete_get_folder_info (gfi_data->object, gfi_data->invocation, variant);
 	g_variant_unref (variant);
 
@@ -395,6 +397,7 @@ handle_create_folder_cb (CamelFolderInfo *fi, gpointer user_data, GError *error)
 	g_variant_builder_add (builder, "(sssuii)", "", "", "", 0, -1, -1);
 	
 	variant = g_variant_builder_end (builder);
+	g_variant_ref (variant);
 	g_variant_builder_unref (builder);
 	
 	ipc (printf("EMailDataStore: folder create success: %s\n", priv->object_path));



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