1
commit bf47a23ee4994597ca0a8757edd5ff0798435517
2
Author: Milan Crha <mcrha@redhat.com>
3
Date: Thu May 6 19:44:34 2010 +0200
5
e_cal_new_from_uri/e_cal_open_default emits runtime warning
7
The warning is "e_source_get_uri () called on source with no absolute URI!"
8
and it's caused by freeing the ESourceList before ECal creation.
9
This change is fixing the issue.
11
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
12
index d1dfdac..7de9052 100644
13
--- a/calendar/libecal/e-cal.c
14
+++ b/calendar/libecal/e-cal.c
15
@@ -879,23 +879,28 @@ e_cal_new (ESource *source, ECalSourceType type)
17
/* for each known source calls check_func, which should return TRUE if the required
18
source have been found. Function returns NULL or the source on which was returned
19
- TRUE by the check_func. Non-NULL pointer should be unreffed by g_object_unref. */
20
+ TRUE by the check_func. Non-NULL pointer should be unreffed by g_object_unref.
22
+ 'sources' is an output parameter and cannot be NULL. When returned non-NULL, then
23
+ should be freed with g_object_unref function. */
25
-search_known_sources (ECalSourceType type, gboolean (*check_func)(ESource *source, gpointer user_data), gpointer user_data, GError **error)
26
+search_known_sources (ECalSourceType type, gboolean (*check_func)(ESource *source, gpointer user_data), gpointer user_data, ESourceList **sources, GError **error)
28
- ESourceList *sources;
33
+ g_return_val_if_fail (sources != NULL, NULL);
34
g_return_val_if_fail (check_func != NULL, NULL);
36
- if (!e_cal_get_sources (&sources, type, &err)) {
39
+ if (!e_cal_get_sources (sources, type, &err)) {
40
g_propagate_error (error, err);
44
- for (g = e_source_list_peek_groups (sources); g; g = g->next) {
45
+ for (g = e_source_list_peek_groups (*sources); g; g = g->next) {
46
ESourceGroup *group = E_SOURCE_GROUP (g->data);
49
@@ -912,8 +917,6 @@ search_known_sources (ECalSourceType type, gboolean (*check_func)(ESource *sourc
53
- g_object_unref (sources);
58
@@ -944,16 +947,19 @@ check_uri (ESource *source, gpointer uri)
60
e_cal_new_from_uri (const gchar *uri, ECalSourceType type)
62
+ ESourceList *sources = NULL;
66
- source = search_known_sources (type, check_uri, (gpointer) uri, NULL);
67
+ source = search_known_sources (type, check_uri, (gpointer) uri, &sources, NULL);
69
source = e_source_new_with_absolute_uri ("", uri);
71
cal = e_cal_new (source, type);
73
g_object_unref (source);
75
+ g_object_unref (sources);
79
@@ -4057,6 +4063,7 @@ check_default (ESource *source, gpointer data)
81
e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointer data, GError **error)
83
+ ESourceList *sources = NULL;
85
ESource *default_source;
87
@@ -4064,9 +4071,11 @@ e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointe
88
e_return_error_if_fail (ecal != NULL, E_CALENDAR_STATUS_INVALID_ARG);
91
- default_source = search_known_sources (type, check_default, NULL, &err);
92
+ default_source = search_known_sources (type, check_default, NULL, &sources, &err);
96
+ g_object_unref (sources);
97
g_propagate_error (error, err);
100
@@ -4105,6 +4114,9 @@ e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointe
105
+ g_object_unref (sources);