[evolution-patches] fix for the bug #328224 [calendar]



Hi, 
  Have attached the patch for the bug
http://bugzilla.gnome.org/show_bug.cgi?id=328224. It fixes the crash and
a memory leak. Publish the calendar in a seperate thread so that the gui
remains responsive. Cleared the gtk store while opening the preferences
dialog so to avoid showing duplicated uris in the preferences tab.


thanks, Chenthill.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/ChangeLog,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 ChangeLog
--- ChangeLog	10 Jan 2006 19:18:06 -0000	1.8
+++ ChangeLog	23 Jan 2006 10:50:26 -0000
@@ -1,3 +1,15 @@
+2006-01-23  Chenthill Palanisamy  <pchenthill novell com>
+
+	Fixes #328224
+	* publish-calendar.c: (publish_uri_async), (url_add_clicked),
+	(url_edit_clicked), ,
+	(publish_uris_set_timeout), (e_plugin_lib_enable): Publish 
+	the calendar in a seperate thread so that the gui remains 
+	responsive.
+	(publish_calendar_locations): Clear the items gtk store.
+	* publish-location.c: (migrateURI), (e_publish_uri_from_xml):
+	If the uri is NULL return back.
+
 2006-01-11  Chenthill Palanisamy  <pchenthill novell com>
 
 	Fixes #325926
Index: publish-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/publish-calendar.c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 publish-calendar.c
--- publish-calendar.c	4 Jan 2006 02:34:45 -0000	1.2
+++ publish-calendar.c	23 Jan 2006 10:50:27 -0000
@@ -47,6 +47,20 @@ void         online_state_changed (EPlug
 void         publish_calendar_context_activate (EPlugin *ep, ECalPopupTargetSource *target);
 GtkWidget   *publish_calendar_locations (EPlugin *epl, EConfigHookItemFactoryData *data);
 static void  update_timestamp (EPublishUri *uri);
+static void publish (EPublishUri *uri);
+
+static void
+publish_uri_async (EPublishUri *uri) 
+{
+	GThread *thread = NULL;
+	GError *error = NULL;
+
+	thread = g_thread_create ((GThreadFunc) publish, uri, FALSE, &error);
+	if (!thread) {
+		g_warning (G_STRLOC ": %s", error->message);
+		g_error_free (error);
+	}
+}
 
 static void
 publish (EPublishUri *uri)
@@ -304,7 +318,7 @@ url_add_clicked (GtkButton *button, Publ
 		url_list_changed (ui);
 		publish_uris = g_slist_prepend (publish_uris, uri);
 		add_timeout (uri);
-		publish (uri);
+		publish_uri_async (uri);
 	} else {
 		g_free (uri);
 	}
@@ -338,7 +352,7 @@ url_edit_clicked (GtkButton *button, Pub
 			g_source_remove (id);
 		add_timeout (uri);
 		url_list_changed (ui);
-		publish (uri);
+		publish_uri_async (uri);
 	}
 }
 
@@ -450,6 +464,9 @@ publish_calendar_locations (EPlugin *epl
 	ui->treeview = glade_xml_get_widget (xml, "url list");
 	if (store == NULL)
 		store = gtk_list_store_new (URL_LIST_N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+	else 
+		gtk_list_store_clear (store);
+
 	gtk_tree_view_set_model (GTK_TREE_VIEW (ui->treeview), GTK_TREE_MODEL (store));
 
 	renderer = gtk_cell_renderer_toggle_new ();
@@ -530,39 +547,53 @@ action_publish (EPlugin *ep, ECalMenuTar
 
 }
 
-int
-e_plugin_lib_enable (EPlugin *ep, int enable)
+static void
+publish_uris_set_timeout (GSList *uris)
 {
-	GSList *uris, *l;
-	GConfClient *client;
+	GSList *l;
 
-	if (enable) {
-		client = gconf_client_get_default ();
-		uris = gconf_client_get_list (client, "/apps/evolution/calendar/publish/uris", GCONF_VALUE_STRING, NULL);
+	uri_timeouts = g_hash_table_new (g_direct_hash, g_direct_equal);
+	l = uris;
 
-		uri_timeouts = g_hash_table_new (g_direct_hash, g_direct_equal);
+	while (l) {
+		gchar *xml = l->data;
 
-		l = uris;
-		while (l) {
-			gchar *xml = l->data;
+		EPublishUri *uri = e_publish_uri_from_xml (xml);
 
-			EPublishUri *uri = e_publish_uri_from_xml (xml);
+		if (!uri->location) {
+			g_free (uri);
+			continue;
+		}
 
-			if (!uri->location) {
-				g_free (uri);
-				continue;
-			}
+		publish_uris = g_slist_prepend (publish_uris, uri);
 
-			publish_uris = g_slist_prepend (publish_uris, uri);
+		/* Add a timeout based on the last publish time */
+		add_offset_timeout (uri);
 
-			/* Add a timeout based on the last publish time */
-			add_offset_timeout (uri);
+		l = g_slist_next (l);
+	}
+	g_slist_foreach (uris, (GFunc) g_free, NULL);
+	g_slist_free (uris);
+}
+
+int
+e_plugin_lib_enable (EPlugin *ep, int enable)
+{
+	GSList *uris;
+	GConfClient *client;
+
+	if (enable) {
+		GThread *thread = NULL;
+		GError *error = NULL;
 
-			l = g_slist_next (l);
-		}
-		g_slist_foreach (uris, (GFunc) g_free, NULL);
-		g_slist_free (uris);
 
+		client = gconf_client_get_default ();
+		uris = gconf_client_get_list (client, "/apps/evolution/calendar/publish/uris", GCONF_VALUE_STRING, NULL);
+		thread = g_thread_create ((GThreadFunc) publish_uris_set_timeout, uris, FALSE, &error);
+		if (!thread) {
+			g_warning ("Could create thread to set timeout for publishing uris : %s", error->message);
+			g_error_free (error);
+		}
 		g_object_unref (client);
 	}
 
Index: publish-location.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/publish-location.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 publish-location.c
--- publish-location.c	19 Dec 2005 10:08:10 -0000	1.1
+++ publish-location.c	23 Jan 2006 10:50:28 -0000
@@ -60,6 +60,12 @@ migrateURI (const gchar *xml, xmlDocPtr 
 	username = xmlGetProp (root, "username");
 
 	vfs_uri = gnome_vfs_uri_new (location);
+	
+	if (!vfs_uri) {
+		g_warning ("Could not form the uri for %s \n", location);
+		goto cleanup;		
+	}
+	
 	gnome_vfs_uri_set_user_name (vfs_uri, username);
 	temp = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD | GNOME_VFS_URI_HIDE_PASSWORD);
 	uri->location = g_strdup_printf ("dav://%s", temp);
@@ -95,9 +101,11 @@ migrateURI (const gchar *xml, xmlDocPtr 
 	g_slist_free (uris);
 	g_object_unref (client);
 
+cleanup:
 	xmlFree (location);
 	xmlFree (enabled);
 	xmlFree (frequency);
+	xmlFree (username);
 	xmlFreeDoc (doc);
 
 	return uri;
@@ -109,7 +117,7 @@ e_publish_uri_from_xml (const gchar *xml
 	xmlDocPtr doc;
 	xmlNodePtr root, p;
 	xmlChar *location, *enabled, *frequency;
-	xmlChar *publish_time, *format;
+	xmlChar *publish_time, *format, *username = NULL;
 	GSList *events = NULL;
 	EPublishUri *uri;
 
@@ -121,8 +129,11 @@ e_publish_uri_from_xml (const gchar *xml
 	if (strcmp (root->name, "uri") != 0)
 		return NULL;
 
-	if (xmlGetProp (root, "username"))
+	if ((username = xmlGetProp (root, "username"))) {
+		xmlFree (username);
 		return migrateURI (xml, doc);
+		
+	}
 
 	uri = g_new0 (EPublishUri, 1);
 


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