[gnome-panel] [clock] Fix confusion between GTime and time_t
- From: Vincent Untz <vuntz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-panel] [clock] Fix confusion between GTime and time_t
- Date: Tue, 11 Aug 2009 18:55:02 +0000 (UTC)
commit 120d77c21e51bc095aa7d5ac2e86a9d9382cc78e
Author: Matthias Drochner <M Drochner fz-juelich de>
Date: Tue Aug 11 20:54:33 2009 +0200
[clock] Fix confusion between GTime and time_t
It was causing crashes on some platforms.
http://bugzilla.gnome.org/show_bug.cgi?id=569113
applets/clock/calendar-client.c | 65 +++++++++++++++++++--------------------
applets/clock/calendar-client.h | 14 ++++----
applets/clock/calendar-window.c | 50 ++++++++++++++++++------------
3 files changed, 69 insertions(+), 60 deletions(-)
---
diff --git a/applets/clock/calendar-client.c b/applets/clock/calendar-client.c
index 4ebd254..bbdb473 100644
--- a/applets/clock/calendar-client.c
+++ b/applets/clock/calendar-client.c
@@ -523,7 +523,7 @@ calendar_client_new (void)
*
* "What?", you say, "Something useful in libc?"
*/
-static inline GTime
+static inline time_t
make_time_for_day_begin (int day,
int month,
int year)
@@ -543,14 +543,14 @@ make_isodate_for_day_begin (int day,
int month,
int year)
{
- GTime utctime;
+ time_t utctime;
utctime = make_time_for_day_begin (day, month, year);
return utctime != -1 ? isodate_from_time_t (utctime) : NULL;
}
-static GTime
+static time_t
get_time_from_property (icalcomponent *ical,
icalproperty_kind prop_kind,
struct icaltimetype (* get_prop_func) (const icalproperty *prop),
@@ -624,7 +624,7 @@ get_ical_description (icalcomponent *ical)
return g_strdup (icalproperty_get_description (prop));
}
-static inline GTime
+static inline time_t
get_ical_start_time (icalcomponent *ical,
icaltimezone *default_zone)
{
@@ -634,7 +634,7 @@ get_ical_start_time (icalcomponent *ical,
default_zone);
}
-static inline GTime
+static inline time_t
get_ical_end_time (icalcomponent *ical,
icaltimezone *default_zone)
{
@@ -646,13 +646,12 @@ get_ical_end_time (icalcomponent *ical,
static gboolean
get_ical_is_all_day (icalcomponent *ical,
- GTime start_gtime,
+ time_t start_time,
icaltimezone *default_zone)
{
icalproperty *prop;
- time_t start_time;
struct tm *start_tm;
- GTime end_time;
+ time_t end_time;
struct icaldurationtype duration;
struct icaltimetype start_icaltime;
@@ -660,7 +659,6 @@ get_ical_is_all_day (icalcomponent *ical,
if (start_icaltime.is_date)
return TRUE;
- start_time = (time_t) start_gtime;
start_tm = gmtime (&start_time);
if (start_tm->tm_sec != 0 ||
start_tm->tm_min != 0 ||
@@ -679,7 +677,7 @@ get_ical_is_all_day (icalcomponent *ical,
return icaldurationtype_as_int (duration) % 86400 == 0;
}
-static inline GTime
+static inline time_t
get_ical_due_time (icalcomponent *ical,
icaltimezone *default_zone)
{
@@ -713,7 +711,7 @@ get_ical_percent_complete (icalcomponent *ical)
return CLAMP (percent_complete, 0, 100);
}
-static inline GTime
+static inline time_t
get_ical_completed_time (icalcomponent *ical,
icaltimezone *default_zone)
{
@@ -909,11 +907,12 @@ resolve_timezone_id (const char *tzid,
static gboolean
calendar_appointment_collect_occurrence (ECalComponent *component,
- GTime occurrence_start,
- GTime occurrence_end,
- GSList **collect_loc)
+ time_t occurrence_start,
+ time_t occurrence_end,
+ gpointer data)
{
CalendarOccurrence *occurrence;
+ GSList **collect_loc = data;
occurrence = g_new0 (CalendarOccurrence, 1);
occurrence->start_time = occurrence_start;
@@ -928,8 +927,8 @@ static void
calendar_appointment_generate_ocurrences (CalendarAppointment *appointment,
icalcomponent *ical,
ECal *source,
- GTime start,
- GTime end,
+ time_t start,
+ time_t end,
icaltimezone *default_zone)
{
ECalComponent *ecal;
@@ -943,7 +942,7 @@ calendar_appointment_generate_ocurrences (CalendarAppointment *appointment,
e_cal_recur_generate_instances (ecal,
start,
end,
- (ECalRecurInstanceFn) calendar_appointment_collect_occurrence,
+ calendar_appointment_collect_occurrence,
&appointment->occurrences,
(ECalRecurResolveTimezoneFn) resolve_timezone_id,
source,
@@ -1160,8 +1159,8 @@ static void
calendar_event_generate_ocurrences (CalendarEvent *event,
icalcomponent *ical,
ECal *source,
- GTime start,
- GTime end,
+ time_t start,
+ time_t end,
icaltimezone *default_zone)
{
if (event->type != CALENDAR_EVENT_APPOINTMENT)
@@ -1332,8 +1331,8 @@ calendar_client_handle_query_result (CalendarClientSource *source,
gboolean emit_signal;
gboolean events_changed;
GList *l;
- GTime month_begin;
- GTime month_end;
+ time_t month_begin;
+ time_t month_end;
client = source->client;
@@ -1846,8 +1845,8 @@ typedef struct
{
CalendarClient *client;
GSList *events;
- GTime start_time;
- GTime end_time;
+ time_t start_time;
+ time_t end_time;
} FilterData;
typedef void (* CalendarEventFilterFunc) (const char *uid,
@@ -1870,8 +1869,8 @@ filter_appointment (const char *uid,
for (l = occurrences; l; l = l->next)
{
CalendarOccurrence *occurrence = l->data;
- GTime start_time = occurrence->start_time;
- GTime end_time = occurrence->end_time;
+ time_t start_time = occurrence->start_time;
+ time_t end_time = occurrence->end_time;
if ((start_time >= filter_data->start_time &&
start_time < filter_data->end_time) ||
@@ -1924,8 +1923,8 @@ static GSList *
calendar_client_filter_events (CalendarClient *client,
GSList *sources,
CalendarEventFilterFunc filter_func,
- GTime start_time,
- GTime end_time)
+ time_t start_time,
+ time_t end_time)
{
FilterData filter_data;
GSList *l;
@@ -1966,8 +1965,8 @@ calendar_client_get_events (CalendarClient *client,
{
GSList *appointments;
GSList *tasks;
- GTime day_begin;
- GTime day_end;
+ time_t day_begin;
+ time_t day_end;
g_return_val_if_fail (CALENDAR_IS_CLIENT (client), NULL);
g_return_val_if_fail (client->priv->day != -1 &&
@@ -2021,8 +2020,8 @@ calendar_client_foreach_appointment_day (CalendarClient *client,
{
GSList *appointments, *l;
gboolean marked_days [32] = { FALSE, };
- GTime month_begin;
- GTime month_end;
+ time_t month_begin;
+ time_t month_end;
int i;
g_return_if_fail (CALENDAR_IS_CLIENT (client));
@@ -2048,7 +2047,7 @@ calendar_client_foreach_appointment_day (CalendarClient *client,
if (appointment->start_time)
{
- GTime day_time = appointment->start_time;
+ time_t day_time = appointment->start_time;
if (day_time >= month_begin)
marked_days [day_from_time_t (day_time)] = TRUE;
@@ -2060,7 +2059,7 @@ calendar_client_foreach_appointment_day (CalendarClient *client,
/* mark the days for the appointment, no need to add an extra one when duration is a multiple of 86400 */
for (day_offset = 1; day_offset <= duration / 86400 && duration != day_offset * 86400; day_offset++)
{
- GTime day_tm = appointment->start_time + day_offset * 86400;
+ time_t day_tm = appointment->start_time + day_offset * 86400;
if (day_tm > month_end)
break;
diff --git a/applets/clock/calendar-client.h b/applets/clock/calendar-client.h
index de8ce9b..3ae3b2f 100644
--- a/applets/clock/calendar-client.h
+++ b/applets/clock/calendar-client.h
@@ -65,8 +65,8 @@ struct _CalendarClientClass
typedef struct
{
- GTime start_time;
- GTime end_time;
+ time_t start_time;
+ time_t end_time;
} CalendarOccurrence;
typedef struct
@@ -77,8 +77,8 @@ typedef struct
char *summary;
char *description;
char *color_string;
- GTime start_time;
- GTime end_time;
+ time_t start_time;
+ time_t end_time;
guint is_all_day : 1;
/* Only used internally */
@@ -92,10 +92,10 @@ typedef struct
char *description;
char *color_string;
char *url;
- GTime start_time;
- GTime due_time;
+ time_t start_time;
+ time_t due_time;
guint percent_complete;
- GTime completed_time;
+ time_t completed_time;
int priority;
} CalendarTask;
diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c
index 2171b6c..69f2bf2 100644
--- a/applets/clock/calendar-window.c
+++ b/applets/clock/calendar-window.c
@@ -343,12 +343,12 @@ handle_tasks_changed (CalendarWindow *calwin)
TASK_COLUMN_UID, task->uid,
TASK_COLUMN_SUMMARY, task->summary,
TASK_COLUMN_DESCRIPTION, task->description,
- TASK_COLUMN_START_TIME, task->start_time,
- TASK_COLUMN_DUE_TIME, task->due_time,
+ TASK_COLUMN_START_TIME, (gint64)task->start_time,
+ TASK_COLUMN_DUE_TIME, (gint64)task->due_time,
TASK_COLUMN_PERCENT_COMPLETE, task->percent_complete,
TASK_COLUMN_PERCENT_COMPLETE_TEXT, percent_complete_text,
TASK_COLUMN_COMPLETED, task->percent_complete == 100,
- TASK_COLUMN_COMPLETED_TIME, task->completed_time,
+ TASK_COLUMN_COMPLETED_TIME, (gint64)task->completed_time,
TASK_COLUMN_COLOR, task->color_string,
TASK_COLUMN_PRIORITY, task->priority,
-1);
@@ -488,15 +488,19 @@ filter_out_tasks (GtkTreeModel *model,
GtkTreeIter *iter,
CalendarWindow *calwin)
{
- GTime start_time;
- GTime completed_time;
- GTime one_day_ago;
+ gint64 start_time64;
+ gint64 completed_time64;
+ time_t start_time;
+ time_t completed_time;
+ time_t one_day_ago;
gboolean visible;
gtk_tree_model_get (model, iter,
- TASK_COLUMN_START_TIME, &start_time,
- TASK_COLUMN_COMPLETED_TIME, &completed_time,
+ TASK_COLUMN_START_TIME, &start_time64,
+ TASK_COLUMN_COMPLETED_TIME, &completed_time64,
-1);
+ start_time = start_time64;
+ completed_time = completed_time64;
one_day_ago = *(calwin->priv->current_time) - (24 * 60 * 60);
@@ -514,7 +518,8 @@ modify_task_text_attributes (GtkTreeModel *model,
gint column,
CalendarWindow *calwin)
{
- GTime due_time;
+ gint64 due_time64;
+ time_t due_time;
PangoAttrList *attr_list;
PangoAttribute *attr;
GtkTreeIter child_iter;
@@ -532,8 +537,10 @@ modify_task_text_attributes (GtkTreeModel *model,
}
gtk_tree_model_get (GTK_TREE_MODEL (calwin->priv->tasks_model),
- &child_iter, TASK_COLUMN_DUE_TIME, &due_time,
+ &child_iter, TASK_COLUMN_DUE_TIME, &due_time64,
-1);
+ due_time = due_time64;
+
if (due_time && due_time > *(calwin->priv->current_time))
return;
@@ -765,12 +772,15 @@ compare_tasks (GtkTreeModel *model,
else if (priority_a > priority_b)
return 1;
else {
- GTime due_time_a, due_time_b;
+ gint64 due_time_a64, due_time_b64;
+ time_t due_time_a, due_time_b;
gtk_tree_model_get (model, a,
- TASK_COLUMN_DUE_TIME, &due_time_a, -1);
+ TASK_COLUMN_DUE_TIME, &due_time_a64, -1);
gtk_tree_model_get (model, b,
- TASK_COLUMN_DUE_TIME, &due_time_b, -1);
+ TASK_COLUMN_DUE_TIME, &due_time_b64, -1);
+ due_time_a = due_time_a64;
+ due_time_b = due_time_b64;
if (due_time_a < due_time_b)
return -1;
@@ -969,9 +979,9 @@ handle_appointments_changed (CalendarWindow *calwin)
APPOINTMENT_COLUMN_URI, appointment->uri,
APPOINTMENT_COLUMN_SUMMARY, appointment->summary,
APPOINTMENT_COLUMN_DESCRIPTION, appointment->description,
- APPOINTMENT_COLUMN_START_TIME, appointment->start_time,
+ APPOINTMENT_COLUMN_START_TIME, (gint64)appointment->start_time,
APPOINTMENT_COLUMN_START_TEXT, start_text,
- APPOINTMENT_COLUMN_END_TIME, appointment->end_time,
+ APPOINTMENT_COLUMN_END_TIME, (gint64)appointment->end_time,
APPOINTMENT_COLUMN_ALL_DAY, appointment->is_all_day,
APPOINTMENT_COLUMN_PIXBUF, appointment->color_string,
-1);
@@ -1161,12 +1171,12 @@ calendar_window_create_tasks_model (CalendarWindow *calwin)
G_TYPE_STRING, /* uid */
G_TYPE_STRING, /* summary */
G_TYPE_STRING, /* description */
- G_TYPE_LONG, /* start time */
- G_TYPE_LONG, /* due time */
+ G_TYPE_INT64, /* start time */
+ G_TYPE_INT64, /* due time */
G_TYPE_UINT, /* percent complete */
G_TYPE_STRING, /* percent complete text */
G_TYPE_BOOLEAN, /* completed */
- G_TYPE_LONG, /* completed time */
+ G_TYPE_INT64, /* completed time */
PANGO_TYPE_ATTR_LIST, /* summary text attributes */
G_TYPE_STRING, /* color */
G_TYPE_INT /* priority */
@@ -1210,9 +1220,9 @@ calendar_window_create_appointments_model (CalendarWindow *calwin)
G_TYPE_STRING, /* uri */
G_TYPE_STRING, /* summary */
G_TYPE_STRING, /* description */
- G_TYPE_LONG, /* start time */
+ G_TYPE_INT64, /* start time */
G_TYPE_STRING, /* start time text */
- G_TYPE_LONG, /* end time */
+ G_TYPE_INT64, /* end time */
G_TYPE_BOOLEAN, /* all day */
G_TYPE_STRING); /* color */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]