[evolution-data-server] e_cal_new_from_uri/e_cal_open_default emits runtime warning
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] e_cal_new_from_uri/e_cal_open_default emits runtime warning
- Date: Thu, 6 May 2010 17:44:12 +0000 (UTC)
commit 2174fdbba0dcf4854c55fbbfbfa6e582d2a6fccf
Author: Milan Crha <mcrha redhat com>
Date: Thu May 6 19:43:59 2010 +0200
e_cal_new_from_uri/e_cal_open_default emits runtime warning
The warning is "e_source_get_uri () called on source with no absolute URI!"
and it's caused by freeing the ESourceList before ECal creation.
This change is fixing the issue.
calendar/libecal/e-cal.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index c8299d5..d28b2b8 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -878,23 +878,28 @@ e_cal_new (ESource *source, ECalSourceType type)
/* for each known source calls check_func, which should return TRUE if the required
source have been found. Function returns NULL or the source on which was returned
- TRUE by the check_func. Non-NULL pointer should be unreffed by g_object_unref. */
+ TRUE by the check_func. Non-NULL pointer should be unreffed by g_object_unref.
+
+ 'sources' is an output parameter and cannot be NULL. When returned non-NULL, then
+ should be freed with g_object_unref function. */
static ESource *
-search_known_sources (ECalSourceType type, gboolean (*check_func)(ESource *source, gpointer user_data), gpointer user_data, GError **error)
+search_known_sources (ECalSourceType type, gboolean (*check_func)(ESource *source, gpointer user_data), gpointer user_data, ESourceList **sources, GError **error)
{
- ESourceList *sources;
ESource *res = NULL;
GSList *g;
GError *err = NULL;
+ g_return_val_if_fail (sources != NULL, NULL);
g_return_val_if_fail (check_func != NULL, NULL);
- if (!e_cal_get_sources (&sources, type, &err)) {
+ *sources = NULL;
+
+ if (!e_cal_get_sources (sources, type, &err)) {
g_propagate_error (error, err);
return NULL;
}
- for (g = e_source_list_peek_groups (sources); g; g = g->next) {
+ for (g = e_source_list_peek_groups (*sources); g; g = g->next) {
ESourceGroup *group = E_SOURCE_GROUP (g->data);
GSList *s;
@@ -911,8 +916,6 @@ search_known_sources (ECalSourceType type, gboolean (*check_func)(ESource *sourc
break;
}
- g_object_unref (sources);
-
return res;
}
@@ -943,16 +946,19 @@ check_uri (ESource *source, gpointer uri)
ECal *
e_cal_new_from_uri (const gchar *uri, ECalSourceType type)
{
+ ESourceList *sources = NULL;
ESource *source;
ECal *cal;
- source = search_known_sources (type, check_uri, (gpointer) uri, NULL);
+ source = search_known_sources (type, check_uri, (gpointer) uri, &sources, NULL);
if (!source)
source = e_source_new_with_absolute_uri ("", uri);
cal = e_cal_new (source, type);
g_object_unref (source);
+ if (sources)
+ g_object_unref (sources);
return cal;
}
@@ -4056,6 +4062,7 @@ check_default (ESource *source, gpointer data)
gboolean
e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointer data, GError **error)
{
+ ESourceList *sources = NULL;
GError *err = NULL;
ESource *default_source;
gboolean res = TRUE;
@@ -4063,9 +4070,11 @@ e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointe
e_return_error_if_fail (ecal != NULL, E_CALENDAR_STATUS_INVALID_ARG);
*ecal = NULL;
- default_source = search_known_sources (type, check_default, NULL, &err);
+ default_source = search_known_sources (type, check_default, NULL, &sources, &err);
if (err) {
+ if (sources)
+ g_object_unref (sources);
g_propagate_error (error, err);
return FALSE;
}
@@ -4104,6 +4113,9 @@ e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointe
*ecal = NULL;
}
+ if (sources)
+ g_object_unref (sources);
+
return res;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]