Blame SOURCES/evolution-ews-3.28.5-double-collection-backend-populate.patch

095e69
From f50530ad101b47d461a345ff2b8b295b86c05d3a Mon Sep 17 00:00:00 2001
095e69
From: Milan Crha <mcrha@redhat.com>
095e69
Date: Thu, 27 Sep 2018 10:51:05 +0200
095e69
Subject: Collection backend schedules two 'populate' requests after going
095e69
 online
095e69
095e69
ECollectionBackend base class makes sure the 'populate' method is called
095e69
after the backend itself goes online, thus there is no need to schedule
095e69
it in the descendant again.
095e69
095e69
Related to https://gitlab.gnome.org/GNOME/evolution-data-server/issues/36
095e69
095e69
diff --git a/src/collection/e-ews-backend.c b/src/collection/e-ews-backend.c
095e69
index 651694b7..d9a973af 100644
095e69
--- a/src/collection/e-ews-backend.c
095e69
+++ b/src/collection/e-ews-backend.c
095e69
@@ -48,7 +48,7 @@ struct _EEwsBackendPrivate {
095e69
 
095e69
 	gboolean need_update_folders;
095e69
 
095e69
-	gulong notify_online_id;
095e69
+	gulong source_changed_id;
095e69
 };
095e69
 
095e69
 struct _SyncFoldersClosure {
095e69
@@ -647,15 +647,21 @@ static void
095e69
 ews_backend_dispose (GObject *object)
095e69
 {
095e69
 	EEwsBackendPrivate *priv;
095e69
+	ESource *source;
095e69
 
095e69
 	priv = E_EWS_BACKEND_GET_PRIVATE (object);
095e69
 
095e69
+	source = e_backend_get_source (E_BACKEND (object));
095e69
+	if (source && priv->source_changed_id) {
095e69
+		g_signal_handler_disconnect (source, priv->source_changed_id);
095e69
+		priv->source_changed_id = 0;
095e69
+	}
095e69
+
095e69
 	g_hash_table_remove_all (priv->folders);
095e69
 
095e69
-	if (priv->connection != NULL) {
095e69
-		g_object_unref (priv->connection);
095e69
-		priv->connection = NULL;
095e69
-	}
095e69
+	g_mutex_lock (&priv->connection_lock);
095e69
+	g_clear_object (&priv->connection);
095e69
+	g_mutex_unlock (&priv->connection_lock);
095e69
 
095e69
 	/* Chain up to parent's dispose() method. */
095e69
 	G_OBJECT_CLASS (e_ews_backend_parent_class)->dispose (object);
095e69
@@ -770,12 +776,8 @@ ews_backend_populate (ECollectionBackend *backend)
095e69
 
095e69
 	ews_backend->priv->need_update_folders = TRUE;
095e69
 
095e69
-	if (!ews_backend->priv->notify_online_id) {
095e69
-		ews_backend->priv->notify_online_id = g_signal_connect (
095e69
-			backend, "notify::online",
095e69
-			G_CALLBACK (ews_backend_populate), NULL);
095e69
-
095e69
-		g_signal_connect (
095e69
+	if (!ews_backend->priv->source_changed_id) {
095e69
+		ews_backend->priv->source_changed_id = g_signal_connect (
095e69
 			source, "changed",
095e69
 			G_CALLBACK (ews_backend_source_changed_cb), ews_backend);
095e69
 	}