From a5db1fe7224c89bed97fe9a8135981a443e3f299 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 13 Aug 2007 14:36:41 +0000 Subject: [PATCH] 2007-08-13 Murray Cumming * src/widgets/modest-account-view.c: (on_account_changed): Do not try to use the human-readable TnyAccount name instead of the ID of the modest account to get the transport account. And unref the transport account. This prevents a g_warning(), and a possible ref leak. pmo-trunk-r2971 --- ChangeLog2 | 8 ++++++++ src/modest-tny-account-store.c | 8 ++++++-- src/widgets/modest-account-view.c | 29 +++++++++++++++++++---------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index 8fa24e4..e95165b 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,13 @@ 2007-08-13 Murray Cumming + * src/widgets/modest-account-view.c: (on_account_changed): + Do not try to use the human-readable TnyAccount name instead of the + ID of the modest account to get the transport account. And unref + the transport account. This prevents a g_warning(), and a possible + ref leak. + +2007-08-13 Murray Cumming + * src/maemo/modest-platform.c: (modest_platform_set_update_interval): Handle the new alarmd error to warn when alarmd is not running, as is the case in diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index a1e31dd..ecec23b 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1373,6 +1373,7 @@ modest_tny_account_store_get_transport_account_for_open_connection (ModestTnyAcc return NULL; /* Get the connection-specific transport acccount, if any: */ + /* Note: This gives us a reference: */ TnyAccount *account = get_smtp_specific_transport_account_for_open_connection (self, account_name); @@ -1382,11 +1383,14 @@ modest_tny_account_store_get_transport_account_for_open_connection (ModestTnyAcc /* The special local folders don't have transport accounts. */ if (strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) == 0) account = NULL; - else + else { + /* Note: This gives us a reference: */ account = modest_tny_account_store_get_server_account (self, account_name, TNY_ACCOUNT_TYPE_TRANSPORT); + } } - + + /* returns a reference. */ return account; } diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index fe15737..488eb2a 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -329,9 +330,10 @@ on_account_changed (TnyAccountStore *account_store, ModestAccountViewPrivate *priv = NULL; TnyTransportAccount *transport_account = NULL; ModestTnySendQueue *send_queue = NULL; - const gchar *account_name = NULL; g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data)); + g_return_if_fail (account); + g_return_if_fail (TNY_IS_ACCOUNT (account)); self = MODEST_ACCOUNT_VIEW (user_data); priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self); @@ -342,16 +344,23 @@ on_account_changed (TnyAccountStore *account_store, update_account_view (priv->account_mgr, self); /* Get transport account */ - account_name = tny_account_get_name (account); - transport_account = (TnyTransportAccount *) + const gchar *modest_account_name = + modest_tny_account_get_parent_modest_account_name_for_server_account (account); + g_return_if_fail (modest_account_name); + + transport_account = (TnyTransportAccount*) modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(), - account_name); - - /* Restart send queue */ - g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT(transport_account)); - send_queue = modest_runtime_get_send_queue (transport_account); - g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(send_queue)); - modest_tny_send_queue_try_to_send (send_queue); + modest_account_name); + + /* Restart send queue */ + if (transport_account) { + g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT(transport_account)); + send_queue = modest_runtime_get_send_queue (transport_account); + g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(send_queue)); + modest_tny_send_queue_try_to_send (send_queue); + + g_object_unref (transport_account); + } } -- 1.7.9.5