From c74a3427f5b22cc82c627918a4eef8e3480ca49b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Dapena=20Paz?= Date: Tue, 16 Feb 2010 18:13:38 +0100 Subject: [PATCH] Update account view happens now in idle, to avoid bad recursions. Fixes NB#156752. --- src/widgets/modest-account-view.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index 792b48b..9fc98ef 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -106,6 +106,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, \ @@ -167,6 +169,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; @@ -190,6 +193,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; @@ -240,13 +248,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. @@ -350,9 +362,24 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) modest_account_view_select_first_account (view); #endif } + + 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, -- 1.7.9.5