[evolution-groupwise/gnome-3-2] Bug #667359 - random crash on config change



commit 75b99a19d5f83fa7585d2ed506b73de2c26d7f45
Author: Vibha Yadav <yvibha suse com>
Date:   Tue Mar 6 19:24:05 2012 +0530

    Bug #667359 - random crash on config change
    
    Getting the gconf entries once while opening the calendar in the main
    thread and later using that for setting default alarms. EFlag is used
    for thread synchronization.

 src/calendar/e-cal-backend-groupwise-utils.c |   15 ++---
 src/calendar/e-cal-backend-groupwise.c       |   73 ++++++++++++++++++++++++++
 src/calendar/e-cal-backend-groupwise.h       |    3 +
 3 files changed, 82 insertions(+), 9 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-groupwise-utils.c b/src/calendar/e-cal-backend-groupwise-utils.c
index 5640ec4..f11ab97 100644
--- a/src/calendar/e-cal-backend-groupwise-utils.c
+++ b/src/calendar/e-cal-backend-groupwise-utils.c
@@ -978,12 +978,11 @@ set_attachments_to_cal_component (EGwItem *item,
 }
 
 static void
-set_default_alarms (ECalComponent *comp)
+set_default_alarms (ECalBackendGroupwise *cbgw,
+			ECalComponent *comp)
 {
 
-	GConfClient *gconf = gconf_client_get_default ();
-
-	if (gconf_client_get_bool (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER, NULL)) {
+	if (e_cal_backend_groupwise_get_default_reminder (cbgw)) {
 
 			ECalComponentAlarm *acomp;
 			gint interval;
@@ -995,8 +994,8 @@ set_default_alarms (ECalComponent *comp)
 			} duration;
 			ECalComponentAlarmTrigger trigger;
 
-			interval = gconf_client_get_int (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, NULL);
-			units = gconf_client_get_string (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL);
+			interval = e_cal_backend_groupwise_get_reminder_interval (cbgw);
+			units = e_cal_backend_groupwise_get_reminder_units (cbgw);
 
 			if (units == NULL)
 				duration = MINUTES;
@@ -1030,7 +1029,6 @@ set_default_alarms (ECalComponent *comp)
 				break;
 			default:
 				e_cal_component_alarm_free (acomp);
-				g_object_unref (gconf);
 				return;
 			}
 
@@ -1039,7 +1037,6 @@ set_default_alarms (ECalComponent *comp)
 
 			e_cal_component_alarm_free (acomp);
 		}
-		g_object_unref (gconf);
 }
 
 static gchar *
@@ -1421,7 +1418,7 @@ e_gw_item_to_cal_component (EGwItem *item,
 			e_cal_component_alarm_free (alarm);
 
 		} else
-			set_default_alarms (comp);
+			set_default_alarms (cbgw, comp);
 
 		break;
 	case E_GW_ITEM_TYPE_TASK :
diff --git a/src/calendar/e-cal-backend-groupwise.c b/src/calendar/e-cal-backend-groupwise.c
index 473fb86..3985666 100644
--- a/src/calendar/e-cal-backend-groupwise.c
+++ b/src/calendar/e-cal-backend-groupwise.c
@@ -36,6 +36,8 @@
 #include <libedataserver/e-data-server-util.h>
 #include <libedataserver/e-xml-hash-utils.h>
 #include <libedataserver/e-url.h>
+#include "libedataserver/e-flag.h"
+#include <gconf/gconf-client.h>
 #include <libedata-cal/e-cal-backend-cache.h>
 #include <libedata-cal/e-cal-backend-file-store.h>
 #include <libedata-cal/e-cal-backend-util.h>
@@ -93,6 +95,13 @@ struct _ECalBackendGroupwisePrivate {
 	/* timeout handler for syncing sendoptions */
 	guint sendoptions_sync_timeout;
 
+	/*Default Alarm Options*/
+	gboolean default_reminder;
+	gint interval;
+	gchar *units;
+	
+	gboolean gconf_props_fetched;
+
 	/* fields for storing info while offline */
 	gchar *user_email;
 
@@ -166,6 +175,30 @@ e_cal_backend_groupwise_priv_unlock (ECalBackendGroupwise *cbgw)
        PRIV_UNLOCK (cbgw->priv);
 }
 
+gboolean
+e_cal_backend_groupwise_get_default_reminder (ECalBackendGroupwise *cbgw)
+{
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), FALSE);
+
+	return cbgw->priv->default_reminder;
+}
+
+gint
+e_cal_backend_groupwise_get_reminder_interval (ECalBackendGroupwise *cbgw)
+{
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), 15);
+
+	return cbgw->priv->interval;
+}
+
+gchar *
+e_cal_backend_groupwise_get_reminder_units (ECalBackendGroupwise *cbgw)
+{
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), NULL);
+
+	return cbgw->priv->units;
+}
+
 static const gchar *
 get_element_type (icalcomponent_kind kind)
 {
@@ -1359,6 +1392,30 @@ in_offline (ECalBackendGroupwise *cbgw)
 	}
 }
 
+struct _GConfSyncData
+{
+	ECalBackendGroupwise *cbgw;
+	EFlag *sync;
+};
+
+static gboolean
+fetch_gconf_props (gpointer data)
+{
+	struct _GConfSyncData *sync_data = (struct _GConfSyncData *) data;
+	ECalBackendGroupwise *cbgw = sync_data->cbgw;
+	ECalBackendGroupwisePrivate *priv = cbgw->priv;
+	GConfClient *gconf;
+
+	gconf = gconf_client_get_default ();
+
+	priv->default_reminder = gconf_client_get_bool (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER, NULL);
+	priv->interval = gconf_client_get_int (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, NULL);
+	priv->units = gconf_client_get_string (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL);
+
+	e_flag_set (sync_data->sync);
+	return FALSE;
+}
+
 /* Open handler for the file backend */
 static void
 e_cal_backend_groupwise_open (ECalBackendSync *backend,
@@ -1379,6 +1436,22 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend,
 	PRIV_LOCK (priv);
 
 	cbgw->priv->read_only = FALSE;
+
+	
+	/* Done just for gnome-32 branch to not access gconf in gthread */
+	if (!priv->gconf_props_fetched) {
+		struct _GConfSyncData sync_data;
+
+		sync_data.cbgw = cbgw;
+		sync_data.sync = e_flag_new ();
+	
+		g_idle_add ((GSourceFunc) fetch_gconf_props, &sync_data);
+		e_flag_wait (sync_data.sync);
+
+		e_flag_free (sync_data.sync);
+		priv->gconf_props_fetched = TRUE;
+	}
+
 	e_cal_backend_notify_online (E_CAL_BACKEND (backend), priv->is_online);
 
 	if (!priv->is_online) {
diff --git a/src/calendar/e-cal-backend-groupwise.h b/src/calendar/e-cal-backend-groupwise.h
index 618e9c8..8020f7f 100644
--- a/src/calendar/e-cal-backend-groupwise.h
+++ b/src/calendar/e-cal-backend-groupwise.h
@@ -65,6 +65,9 @@ void    e_cal_backend_groupwise_notify_error_code (ECalBackendGroupwise *cbgw, E
 const gchar *e_cal_backend_groupwise_get_container_id (ECalBackendGroupwise *cbgw);
 void e_cal_backend_groupwise_priv_lock (ECalBackendGroupwise *cbgw);
 void e_cal_backend_groupwise_priv_unlock (ECalBackendGroupwise *cbgw);
+gboolean e_cal_backend_groupwise_get_default_reminder (ECalBackendGroupwise *cbgw);
+gint e_cal_backend_groupwise_get_reminder_interval (ECalBackendGroupwise *cbgw);
+gchar * e_cal_backend_groupwise_get_reminder_units (ECalBackendGroupwise *cbgw);
 
 G_END_DECLS
 



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