[evolution-data-server] Revert "Add e_cal_backend_store_save()."



commit b1566ed0edd32cc6ecba7da06cbf07e14f6f5643
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jan 9 14:24:30 2013 -0500

    Revert "Add e_cal_backend_store_save()."
    
    This reverts two commits:
    
        a68f14d5573b72ada7e04d090af47f879455e0bc
        ad12a30f349d5ca1a44fcdd607d272a8149ab9cf
    
    Thought of a better way to solve the final save problem that doesn't
    involve adding new API or modifying backends.

 calendar/backends/caldav/e-cal-backend-caldav.c    |    1 -
 calendar/backends/http/e-cal-backend-http.c        |   13 +++---
 calendar/backends/weather/e-cal-backend-weather.c  |   30 +++-----------
 calendar/libedata-cal/e-cal-backend-store.c        |   42 +++-----------------
 calendar/libedata-cal/e-cal-backend-store.h        |    1 -
 .../libedata-cal/libedata-cal-sections.txt         |    1 -
 6 files changed, 19 insertions(+), 69 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index d854b67..f7f7635 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -4966,7 +4966,6 @@ e_cal_backend_caldav_dispose (GObject *object)
 	g_free (priv->schedule_outbox_url);
 
 	if (priv->store != NULL) {
-		e_cal_backend_store_save (priv->store);
 		g_object_unref (priv->store);
 	}
 
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 7f3fecf..c2db383 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -119,12 +119,6 @@ e_cal_backend_http_dispose (GObject *object)
 		priv->reload_timeout_id = 0;
 	}
 
-	if (priv->store) {
-		e_cal_backend_store_save (priv->store);
-		g_object_unref (priv->store);
-		priv->store = NULL;
-	}
-
 	if (priv->soup_session) {
 		soup_session_abort (priv->soup_session);
 		g_object_unref (priv->soup_session);
@@ -149,6 +143,13 @@ e_cal_backend_http_finalize (GObject *object)
 
 	priv = E_CAL_BACKEND_HTTP_GET_PRIVATE (object);
 
+	/* Clean up */
+
+	if (priv->store) {
+		g_object_unref (priv->store);
+		priv->store = NULL;
+	}
+
 	g_free (priv->uri);
 	g_free (priv->password);
 
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index c65ab4b..c9e2da8 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -758,46 +758,29 @@ e_cal_backend_weather_notify_online_cb (ECalBackend *backend,
 	}
 }
 
+/* Finalize handler for the weather backend */
 static void
-e_cal_backend_weather_dispose (GObject *object)
+e_cal_backend_weather_finalize (GObject *object)
 {
 	ECalBackendWeatherPrivate *priv;
 
 	priv = E_CAL_BACKEND_WEATHER_GET_PRIVATE (object);
 
-	if (priv->reload_timeout_id > 0) {
+	if (priv->reload_timeout_id)
 		g_source_remove (priv->reload_timeout_id);
-		priv->reload_timeout_id = 0;
-	}
 
-	if (priv->begin_retrival_id > 0) {
+	if (priv->begin_retrival_id)
 		g_source_remove (priv->begin_retrival_id);
-		priv->begin_retrival_id = 0;
-	}
 
-	if (priv->store != NULL) {
-		e_cal_backend_store_save (priv->store);
+	if (priv->store) {
 		g_object_unref (priv->store);
 		priv->store = NULL;
 	}
 
-	/* Chain up to parent's dispose() method. */
-	G_OBJECT_CLASS (e_cal_backend_weather_parent_class)->
-		dispose (object);
-}
-
-static void
-e_cal_backend_weather_finalize (GObject *object)
-{
-	ECalBackendWeatherPrivate *priv;
-
-	priv = E_CAL_BACKEND_WEATHER_GET_PRIVATE (object);
-
 	g_free (priv->city);
 
 	/* Chain up to parent's finalize() method. */
-	G_OBJECT_CLASS (e_cal_backend_weather_parent_class)->
-		finalize (object);
+	G_OBJECT_CLASS (e_cal_backend_weather_parent_class)->finalize (object);
 }
 
 /* Object initialization function for the weather backend */
@@ -827,7 +810,6 @@ e_cal_backend_weather_class_init (ECalBackendWeatherClass *class)
 	backend_class = (ECalBackendClass *) class;
 	sync_class = (ECalBackendSyncClass *) class;
 
-	object_class->dispose = e_cal_backend_weather_dispose;
 	object_class->finalize = e_cal_backend_weather_finalize;
 
 	sync_class->get_backend_property_sync	= e_cal_backend_weather_get_backend_property;
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index 084ce0b..cd41f2b 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -477,17 +477,21 @@ cal_backend_store_dispose (GObject *object)
 {
 	ECalBackendStorePrivate *priv;
 	ETimezoneCache *timezone_cache;
+	gboolean save_needed = FALSE;
 
 	priv = E_CAL_BACKEND_STORE_GET_PRIVATE (object);
 
-	/* Too late to save, we probably already
-	 * lost our weak ETimezoneCache reference. */
+	/* If a save is scheduled, cancel it and save now. */
 	g_mutex_lock (&priv->save_timeout_lock);
 	if (priv->save_timeout_id > 0) {
 		g_source_remove (priv->save_timeout_id);
 		priv->save_timeout_id = 0;
+		save_needed = TRUE;
 	}
 	g_mutex_unlock (&priv->save_timeout_lock);
+	if (save_needed)
+		cal_backend_store_save_cache_now (
+			E_CAL_BACKEND_STORE (object));
 
 	timezone_cache = g_weak_ref_get (&priv->timezone_cache);
 	if (timezone_cache != NULL) {
@@ -1066,40 +1070,6 @@ e_cal_backend_store_load (ECalBackendStore *store)
 }
 
 /**
- * e_cal_backend_store_save:
- * @store: an #ECalBackendStore
- *
- * Changes to @store are normally saved to disk automatically after a
- * short delay.  However when @store is about to be finalized, changes
- * should be saved to disk immediately so they are not lost.
- *
- * This function cancels the automatic save delay and saves changes to
- * disk immediately.  If no changes have been made since the last save,
- * the function does nothing.
- *
- * Since: 3.8
- **/
-void
-e_cal_backend_store_save (ECalBackendStore *store)
-{
-	gboolean save_needed = FALSE;
-
-	g_return_if_fail (E_IS_CAL_BACKEND_STORE (store));
-
-	/* If a save is scheduled, cancel it and save now. */
-	g_mutex_lock (&store->priv->save_timeout_lock);
-	if (store->priv->save_timeout_id > 0) {
-		g_source_remove (store->priv->save_timeout_id);
-		store->priv->save_timeout_id = 0;
-		save_needed = TRUE;
-	}
-	g_mutex_unlock (&store->priv->save_timeout_lock);
-
-	if (save_needed)
-		cal_backend_store_save_cache_now (store);
-}
-
-/**
  * e_cal_backend_store_clean:
  *
  * Since: 2.28
diff --git a/calendar/libedata-cal/e-cal-backend-store.h b/calendar/libedata-cal/e-cal-backend-store.h
index 0db8ece..7816cfd 100644
--- a/calendar/libedata-cal/e-cal-backend-store.h
+++ b/calendar/libedata-cal/e-cal-backend-store.h
@@ -107,7 +107,6 @@ ETimezoneCache *
 		e_cal_backend_store_ref_timezone_cache
 						(ECalBackendStore *store);
 gboolean	e_cal_backend_store_load	(ECalBackendStore *store);
-void		e_cal_backend_store_save	(ECalBackendStore *store);
 gboolean	e_cal_backend_store_is_loaded	(ECalBackendStore *store);
 gboolean	e_cal_backend_store_clean	(ECalBackendStore *store);
 ECalComponent *	e_cal_backend_store_get_component
diff --git a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
index 72488f3..d4bf314 100644
--- a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
+++ b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
@@ -130,7 +130,6 @@ e_cal_backend_store_new
 e_cal_backend_store_get_path
 e_cal_backend_store_ref_timezone_cache
 e_cal_backend_store_load
-e_cal_backend_store_save
 e_cal_backend_store_is_loaded
 e_cal_backend_store_clean
 e_cal_backend_store_get_component



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