aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-service.c
diff options
context:
space:
mode:
authorAntti Kaijanmäki <antti.kaijanmaki@canonical.com>2011-09-29 22:57:50 +0300
committerAntti Kaijanmäki <antti.kaijanmaki@canonical.com>2011-09-29 22:57:50 +0300
commit8c01596f429b68ff6a70a5b4e6edfacda22d9f70 (patch)
tree1b2884f5ca863466ce51d90cc1f6b73fef4aba94 /src/datetime-service.c
parent6e9eb952ae9f2703c5e06b62ede0ef4b1ddfda3f (diff)
downloadayatana-indicator-datetime-8c01596f429b68ff6a70a5b4e6edfacda22d9f70.tar.gz
ayatana-indicator-datetime-8c01596f429b68ff6a70a5b4e6edfacda22d9f70.tar.bz2
ayatana-indicator-datetime-8c01596f429b68ff6a70a5b4e6edfacda22d9f70.zip
Fix 100% CPU usage (LP: #774071)
Diffstat (limited to 'src/datetime-service.c')
-rw-r--r--src/datetime-service.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c
index 80c0b57..25572ee 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -1,3 +1,4 @@
+/*-*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
An indicator to time and date related information in the menubar.
@@ -430,7 +431,10 @@ static guint ecaltimer = 0;
static void
start_ecal_timer(void)
{
- if (ecaltimer != 0) g_source_remove(ecaltimer);
+ if (ecaltimer != 0) {
+ g_source_remove(ecaltimer);
+ ecaltimer = 0;
+ }
if (update_appointment_menu_items(NULL))
ecaltimer = g_timeout_add_seconds(60*5, update_appointment_menu_items, NULL);
}
@@ -438,7 +442,10 @@ start_ecal_timer(void)
static void
stop_ecal_timer(void)
{
- if (ecaltimer != 0) g_source_remove(ecaltimer);
+ if (ecaltimer != 0) {
+ g_source_remove(ecaltimer);
+ ecaltimer = 0;
+ }
}
static gboolean
idle_start_ecal_timer (gpointer data)
@@ -748,9 +755,10 @@ update_appointment_menu_items (gpointer user_data)
for (l = comp_instances; l; l = l->next) {
const struct comp_instance *ci = l->data;
g_object_unref(ci->comp);
- g_list_free(comp_instances);
- comp_instances = NULL;
}
+ g_list_free(comp_instances);
+ comp_instances = NULL;
+
}
GSList *cal_list = gconf_client_get_list(gconf, "/apps/evolution/calendar/display/selected_calendars", GCONF_VALUE_STRING, &gerror);
if (gerror) {
@@ -759,6 +767,7 @@ update_appointment_menu_items (gpointer user_data)
gerror = NULL;
cal_list = NULL;
}
+
// Generate instances for all sources
for (g = e_source_list_peek_groups (sources); g; g = g->next) {
ESourceGroup *group = E_SOURCE_GROUP (g->data);
@@ -779,6 +788,7 @@ update_appointment_menu_items (gpointer user_data)
g_debug("Failed to set ecal default timezone %s", gerror->message);
g_error_free(gerror);
gerror = NULL;
+ g_object_unref(ecal);
continue;
}
@@ -786,8 +796,9 @@ update_appointment_menu_items (gpointer user_data)
g_debug("Failed to get ecal sources %s", gerror->message);
g_error_free(gerror);
gerror = NULL;
+ g_object_unref(ecal);
continue;
- }
+ }
const gchar *ecal_uid = e_source_peek_uid(source);
gboolean match = FALSE;
g_debug("Checking ecal_uid is enabled: %s", ecal_uid);
@@ -798,10 +809,14 @@ update_appointment_menu_items (gpointer user_data)
break;
}
}
- if (!match) continue;
+ if (!match) {
+ g_object_unref(ecal);
+ continue;
+ }
g_debug("ecal_uid is enabled, generating instances");
e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, (gpointer) source);
+ g_object_unref(ecal);
}
}
g_debug("Number of ECalComponents returned: %d", g_list_length(comp_instances));