2007-08-13 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Mon, 13 Aug 2007 14:36:41 +0000 (14:36 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Mon, 13 Aug 2007 14:36:41 +0000 (14:36 +0000)
* 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
src/modest-tny-account-store.c
src/widgets/modest-account-view.c

index 8fa24e4..e95165b 100644 (file)
@@ -1,5 +1,13 @@
 2007-08-13  Murray Cumming  <murrayc@murrayc.com>
 
+       * 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  <murrayc@murrayc.com>
+
        * 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  
index a1e31dd..ecec23b 100644 (file)
@@ -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;
 }
 
index fe15737..488eb2a 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <modest-account-mgr.h>
 #include <modest-account-mgr-helpers.h>
+#include <modest-tny-account.h>
 #include <modest-text-utils.h>
 #include <modest-runtime.h>
 
@@ -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);
+       }
 }