From: José Dapena Paz Date: Tue, 16 Feb 2010 17:13:38 +0000 (+0100) Subject: Update account view happens now in idle, to avoid bad recursions. X-Git-Url: http://vcs.maemo.org/git/?p=modest;a=commitdiff_plain;h=0eecab033317f175f3c4ba3aac3f64d4169bed30 Update account view happens now in idle, to avoid bad recursions. Fixes NB#156752. --- diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index 803a260..1476aa3 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -100,6 +100,8 @@ struct _ModestAccountViewPrivate { GtkTreeViewColumn *account_name_column; GtkCellRenderer *account_name_renderer; + + guint update_account_view_idle_id; }; #define MODEST_ACCOUNT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_ACCOUNT_VIEW, \ @@ -161,6 +163,7 @@ modest_account_view_init (ModestAccountView *obj) priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj); priv->sig_handlers = NULL; + priv->update_account_view_idle_id = 0; priv->datetime_formatter = modest_datetime_formatter_new (); priv->picker_mode = FALSE; @@ -184,6 +187,11 @@ modest_account_view_finalize (GObject *obj) priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj); + if (priv->update_account_view_idle_id > 0) { + g_source_remove (priv->update_account_view_idle_id); + priv->update_account_view_idle_id = 0; + } + if (priv->datetime_formatter) { g_object_unref (priv->datetime_formatter); priv->datetime_formatter = NULL; @@ -234,13 +242,17 @@ get_last_updated_string(ModestAccountView *self, ModestAccountMgr* account_mgr, return last_updated_string; } -static void -update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) +static gboolean +update_account_view_idle (gpointer userdata) { - GSList *account_names, *cursor; + ModestAccountView *view; ModestAccountViewPrivate *priv; - + ModestAccountMgr *account_mgr; + GSList *account_names, *cursor; + + view = MODEST_ACCOUNT_VIEW (userdata); priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(view); + account_mgr = modest_runtime_get_account_mgr (); /* Get the ID of the currently-selected account, * so we can select it again after rebuilding the list. @@ -332,9 +344,24 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) modest_account_view_select_account (view, selected_name); g_free (selected_name); } + + priv->update_account_view_idle_id = 0; + return FALSE; } static void +update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) +{ + ModestAccountViewPrivate *priv; + priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(view); + + if (priv->update_account_view_idle_id == 0) { + priv->update_account_view_idle_id = g_idle_add (update_account_view_idle, (gpointer) view); + } +} + + +static void on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name, gboolean busy,