diff options
author | Hiroyuki Ikezoe <poincare@ikezoe.net> | 2007-10-07 09:26:26 +0800 |
---|---|---|
committer | Hiroyuki Ikezoe <hiikezoe@src.gnome.org> | 2007-10-07 09:26:26 +0800 |
commit | f1b6fa21b9bfb030ad838f36abf2107ae190036c (patch) | |
tree | 8f0f95bdf136865d444cbad7fdf799ab228fe159 /calendar | |
parent | e093117ef673e80c54e603ee0ed1dbd487a4bcb6 (diff) | |
download | gsoc2013-evolution-f1b6fa21b9bfb030ad838f36abf2107ae190036c.tar.gz gsoc2013-evolution-f1b6fa21b9bfb030ad838f36abf2107ae190036c.tar.zst gsoc2013-evolution-f1b6fa21b9bfb030ad838f36abf2107ae190036c.zip |
** Fix for bug #455862 Plugged memory leaks.
2007-10-07 Hiroyuki Ikezoe <poincare@ikezoe.net>
** Fix for bug #455862
Plugged memory leaks.
* gui/comp-util.c:
* gui/comp-util.h:(cal_comp_util_get_n_icons): A new function to
get the number of icons owned by ECalComponent.
* gui/e-day-view-main-item.c:
* gui/e-day-view.c:
* gui/e-week-view-event-item.c:
* gui/e-week-view.c: Use cal_comp_util_get_n_icons.
svn path=/trunk/; revision=34359
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 14 | ||||
-rw-r--r-- | calendar/gui/comp-util.c | 38 | ||||
-rw-r--r-- | calendar/gui/comp-util.h | 3 | ||||
-rw-r--r-- | calendar/gui/e-day-view-main-item.c | 22 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 27 | ||||
-rw-r--r-- | calendar/gui/e-week-view-event-item.c | 22 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 16 |
7 files changed, 66 insertions, 76 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a4d971d48a..be8d4dd67f 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,17 @@ +2007-10-07 Hiroyuki Ikezoe <poincare@ikezoe.net> + + ** Fix for bug #455862 + Plugged memory leaks. + + * gui/comp-util.c: + * gui/comp-util.h:(cal_comp_util_get_n_icons): A new function to + get the number of icons owned by ECalComponent. + + * gui/e-day-view-main-item.c: + * gui/e-day-view.c: + * gui/e-week-view-event-item.c: + * gui/e-week-view.c: Use cal_comp_util_get_n_icons. + 2007-10-05 Milan Crha <mcrha@redhat.com> * gui/alarm-notify/alarm-queue.c: (alarm_queue_remove_client): diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 61f2260949..6919302b73 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -28,6 +28,8 @@ #include "calendar-config.h" #include "comp-util.h" #include "dialogs/delete-comp.h" +#include <libecal/e-cal-component.h> +#include "e-util/e-categories-config.h" @@ -394,3 +396,39 @@ cal_comp_memo_new_with_defaults (ECal *client) return comp; } + +/** + * cal_comp_util_get_n_icons: + * @comp: A calendar component object. + * + * Get the number of icons owned by the component. + * + * Returns: the number of icons owned by the component. + **/ +gint +cal_comp_util_get_n_icons (ECalComponent *comp) +{ + GSList *categories_list, *elem; + gint num_icons = 0; + + g_return_val_if_fail (comp != NULL, 0); + g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), 0); + + e_cal_component_get_categories_list (comp, &categories_list); + for (elem = categories_list; elem; elem = elem->next) { + char *category; + GdkPixmap *pixmap = NULL; + GdkBitmap *mask = NULL; + + category = (char *) elem->data; + if (e_categories_config_get_icon_for (category, &pixmap, &mask)) { + num_icons++; + g_object_unref (pixmap); + if (mask) + g_object_unref (mask); + } + } + e_cal_component_free_categories_list (categories_list); + + return num_icons; +} diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h index 57006765ae..651fde686a 100644 --- a/calendar/gui/comp-util.h +++ b/calendar/gui/comp-util.h @@ -36,6 +36,9 @@ gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp, ECal *client, icaltimezone *zone); +/* Returns the number of icons owned by the ECalComponent */ +gint cal_comp_util_get_n_icons (ECalComponent *comp); + gboolean cal_comp_is_on_server (ECalComponent *comp, ECal *client); diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index 052f517b6f..8aa27efdfc 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -36,6 +36,7 @@ #include "e-day-view-main-item.h" #include "ea-calendar.h" #include "e-calendar-view.h" +#include "comp-util.h" #include <libecal/e-cal-time-util.h> #include <e-calendar-view.h> @@ -655,16 +656,9 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, num_icons++; } - e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; + num_icons += cal_comp_util_get_n_icons (comp); - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } + e_cal_component_get_categories_list (comp, &categories_list); if (num_icons != 0) { if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD) @@ -1800,16 +1794,8 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, num_icons++; } + num_icons += cal_comp_util_get_n_icons (comp); e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } if (num_icons != 0) { if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD) diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 73708129d0..e43c71bf7f 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -5625,8 +5625,6 @@ e_day_view_reshape_long_event (EDayView *day_view, } if (show_icons) { - GSList *categories_list, *elem; - if (e_cal_component_has_alarms (comp)) num_icons++; if (e_cal_component_has_recurrences (comp) || e_cal_component_is_instance (comp)) @@ -5638,17 +5636,7 @@ e_day_view_reshape_long_event (EDayView *day_view, num_icons++; if (e_cal_component_has_attachments (comp)) num_icons++; - e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } - e_cal_component_free_categories_list (categories_list); + num_icons += cal_comp_util_get_n_icons (comp); } if (!event->canvas_item) { @@ -5798,7 +5786,6 @@ e_day_view_reshape_day_event (EDayView *day_view, if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE || day_view->resize_event_day != day || day_view->resize_event_num != event_num) { - GSList *categories_list, *elem; ECalComponent *comp; comp = e_cal_component_new (); @@ -5815,17 +5802,7 @@ e_day_view_reshape_day_event (EDayView *day_view, if (e_cal_component_has_organizer (comp)) num_icons++; - e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } - e_cal_component_free_categories_list (categories_list); + num_icons += cal_comp_util_get_n_icons (comp); g_object_unref(comp); } diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index e786d5a741..16fa41102d 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -37,6 +37,7 @@ #include <gtk/gtksignal.h> #include "e-calendar-view.h" +#include "comp-util.h" #include <text/e-text.h> @@ -632,16 +633,8 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, num_icons++; } + num_icons += cal_comp_util_get_n_icons (comp); e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } icon_x_inc = E_WEEK_VIEW_ICON_WIDTH + E_WEEK_VIEW_ICON_X_PAD; @@ -1351,16 +1344,9 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, num_icons++; } - e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; + num_icons += cal_comp_util_get_n_icons (comp); - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } + e_cal_component_get_categories_list (comp, &categories_list); icon_x_inc = E_WEEK_VIEW_ICON_WIDTH + E_WEEK_VIEW_ICON_X_PAD; diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index f2fe95c2b7..6dfd47e331 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2698,8 +2698,6 @@ e_week_view_reshape_event_span (EWeekView *week_view, /* Calculate how many icons we need to show. */ num_icons = 0; if (show_icons) { - GSList *categories_list, *elem; - if (e_cal_component_has_alarms (comp)) num_icons++; if (e_cal_component_has_recurrences (comp) || e_cal_component_is_instance (comp)) @@ -2708,19 +2706,7 @@ e_week_view_reshape_event_span (EWeekView *week_view, num_icons++; if (event->different_timezone) num_icons++; - - e_cal_component_get_categories_list (comp, &categories_list); - for (elem = categories_list; elem; elem = elem->next) { - char *category; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - category = (char *) elem->data; - if (e_categories_config_get_icon_for (category, &pixmap, &mask)) - num_icons++; - } - - e_cal_component_free_categories_list (categories_list); + num_icons += cal_comp_util_get_n_icons (comp); } /* Create the background canvas item if necessary. */ |