aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-05-06 18:43:14 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-05-06 18:43:14 +0800
commit10ee8953e2d461f3164cbc32784af1ab887aa0c7 (patch)
treee4604f9a32f3e0b569e566216d4d2a969734a23d /calendar/cal-util
parent154973985a05b17e29e1588adccaee0c17dd11d5 (diff)
downloadgsoc2013-evolution-10ee8953e2d461f3164cbc32784af1ab887aa0c7.tar.gz
gsoc2013-evolution-10ee8953e2d461f3164cbc32784af1ab887aa0c7.tar.zst
gsoc2013-evolution-10ee8953e2d461f3164cbc32784af1ab887aa0c7.zip
added guint ref_count to iCalObject struct, and ical_object_ref/unref()
2000-05-06 Damon Chaplin <damon@helixcode.com> * cal-util/calobj.[hc]: added guint ref_count to iCalObject struct, and ical_object_ref/unref() functions. I've updated all the gui/ stuff to use ref_counts but I haven't touched the pcs/ stuff. Maybe just using ical_object_destroy() is OK there. * gui/gncal-todo.c: * gui/calendar-commands.c: * gui/eventedit.c: * gui/e-week-view.c: * gui/e-day-view.c: use refcounting for iCalObjects. * gui/e-day-view-main-item.c: * gui/e-day-view-top-item.c: * gui/e-day-view.c: try not to ever draw outside the event, even when the event is very small. 2000-05-05 Damon Chaplin <damon@helixcode.com> * gui/e-day-view.c: don't allow recurring events to be resized or dragged, and don't show the resize/drag cursors. Actually it may be better to let the user do the resize/drag and then ask them what they want to do - change the single occurrence or the entire series. * gui/e-day-view-time-item.c (e_day_view_time_item_show_popup_menu): use e_auto_kill_popup_menu_on_hide() to destroy the popup menu. * gui/popup-menu.c: include e-gui-utils.h svn path=/trunk/; revision=2823
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/calobj.c21
-rw-r--r--calendar/cal-util/calobj.h11
2 files changed, 32 insertions, 0 deletions
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index cc9c1636c7..9691d31c11 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -66,6 +66,8 @@ ical_object_new (void)
ico->pilot_id = 0;
ico->pilot_status = ICAL_PILOT_SYNC_MOD;
+ ico->ref_count = 1;
+
return ico;
}
@@ -91,6 +93,23 @@ ical_new (char *comment, char *organizer, char *summary)
return ico;
}
+
+void
+ical_object_ref (iCalObject *ico)
+{
+ ico->ref_count++;
+}
+
+
+void
+ical_object_unref (iCalObject *ico)
+{
+ ico->ref_count--;
+ if (ico->ref_count == 0)
+ ical_object_destroy (ico);
+}
+
+
static void
my_free (gpointer data, gpointer user_dat_ignored)
{
@@ -588,6 +607,8 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
return 0;
}
+ ical->ref_count = 1;
+
/* uid */
if (has (o, VCUniqueStringProp)){
ical->uid = g_strdup (str_val (vo));
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 25954b8098..e44b2ad7b1 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -221,6 +221,8 @@ typedef struct {
/* Pilot */
iCalPilotState pilot_status; /* Status information */
guint32 pilot_id; /* Pilot ID */
+
+ guint ref_count;
} iCalObject;
/* The callback for the recurrence generator */
@@ -228,7 +230,16 @@ typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *);
iCalObject *ical_new (char *comment, char *organizer, char *summary);
iCalObject *ical_object_new (void);
+
+/* iCalObjects are created with a refcount of 1. When it drops to 0 it is
+ destroyed with ical_object_destroy(). To maintain backwards compatability
+ ical_object_destroy() can still be used, though code which uses it should
+ not be mixed with code that uses refcounts. */
+void ical_object_ref (iCalObject *ico);
+void ical_object_unref (iCalObject *ico);
+
void ical_object_destroy (iCalObject *ico);
+
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
iCalObject *ical_object_duplicate (iCalObject *o);