* fix some leaks, turn an assert into a runtime warning
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 28 Aug 2007 06:51:52 +0000 (06:51 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 28 Aug 2007 06:51:52 +0000 (06:51 +0000)
pmo-trunk-r3101

src/modest-cache-mgr.c
src/modest-tny-account-store.c

index 87023d5..dfc5c22 100644 (file)
@@ -198,13 +198,6 @@ modest_cache_mgr_get_cache   (ModestCacheMgr* self, ModestCacheMgrCacheType type
 }
 
 
-static gboolean
-always_true (gpointer key, gpointer value, gpointer user_data)
-{
-       return TRUE;
-}
-
-
 void
 modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type)
 {
@@ -213,13 +206,12 @@ modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type)
        
        g_return_if_fail (self);
        g_return_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM);
-
+       
        priv  = MODEST_CACHE_MGR_GET_PRIVATE(self);
 
        cache = get_cache (priv, type);
        if (cache)
-               g_hash_table_foreach_remove (cache, always_true, NULL);
-       /*  g_hash_table_remove_all (cache) in only available since GLIB 2.12 */
+               g_hash_table_destroy (cache);
 }
 
 
@@ -228,7 +220,7 @@ modest_cache_mgr_flush_all (ModestCacheMgr *self)
 {
        int i;
        g_return_if_fail (self);
-
+       
        for (i = 0; i != MODEST_CACHE_MGR_CACHE_TYPE_NUM; ++i)
                modest_cache_mgr_flush (self, i);       
 }
index e46ca55..4dad898 100644 (file)
@@ -287,7 +287,7 @@ modest_tny_account_store_instance_init (ModestTnyAccountStore *obj)
         * so we can avoid showing the account settings twice for the same modest account: */                                 
        priv->account_settings_dialog_hash = g_hash_table_new_full (g_str_hash, g_str_equal, 
                                                                    g_free, NULL);
-                                                             
+       
        /* Respond to volume mounts and unmounts, such 
         * as the insertion/removal of the memory card: */
        /* This is a singleton, so it does not need to be unrefed. */
@@ -789,6 +789,11 @@ modest_tny_account_store_finalize (GObject *obj)
                priv->password_hash = NULL;
        }
 
+       if (priv->account_settings_dialog_hash) {
+               g_hash_table_destroy (priv->account_settings_dialog_hash);
+               priv->account_settings_dialog_hash = NULL;
+       }
+
        /* Disconnect VFS signals */
        volume_monitor = gnome_vfs_get_volume_monitor ();
        if (g_signal_handler_is_connected (volume_monitor, 
@@ -1611,11 +1616,14 @@ insert_account (ModestTnyAccountStore *self,
                folders = tny_simple_list_new ();
                tny_folder_store_get_folders (TNY_FOLDER_STORE (account_outbox),
                                              folders, NULL, NULL);
-               g_assert (tny_list_get_length (folders) == 1);
+               if (tny_list_get_length (folders) != 1)
+                       g_warning ("%s: there should be only one outbox folder, but found %d!",
+                                  __FUNCTION__, tny_list_get_length (folders));
                
                iter_folders = tny_list_create_iterator (folders);
                per_account_outbox = TNY_FOLDER (tny_iterator_get_current (iter_folders));
                g_object_unref (iter_folders);
+               g_object_unref (folders);
                g_object_unref (account_outbox);
 
                /* Add the outbox of the new per-account-local-outbox