* Fixed a memory corruption problem while initializing threads
authorSergio Villar Senin <svillar@igalia.com>
Tue, 19 Jun 2007 11:50:54 +0000 (11:50 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 19 Jun 2007 11:50:54 +0000 (11:50 +0000)
* Added a poke_status call whenever we update an account with the send&receive button

pmo-trunk-r2309

src/modest-init.c
src/modest-mail-operation.c
src/modest-main.c

index ce90fbc..98ed12d 100644 (file)
@@ -51,6 +51,7 @@
 #ifdef MODEST_PLATFORM_MAEMO
 #include "modest-hildon-includes.h"
 #endif
+#include <locale.h>
 
 static gboolean init_header_columns (ModestConf *conf, gboolean overwrite);
 static gboolean init_default_account_maybe  (ModestAccountMgr *acc_mgr);
@@ -185,11 +186,6 @@ modest_init_init_core (void)
        init_i18n();
        init_debug_g_type();
        init_debug_logging();
-
-       if (!g_thread_supported())
-               g_thread_init(NULL);
-       
-       gdk_threads_init ();
        
        if (!modest_runtime_init()) {
                modest_init_uninit ();
index 43e893a..0199d9e 100644 (file)
@@ -957,10 +957,6 @@ update_account_thread (gpointer thr_user_data)
                        iter = tny_list_create_iterator (observer->new_headers);
                        while (!tny_iterator_is_done (iter)) {
                                TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
-                               /* printf ("  DEBUG1.2 %s: checking size: account=%s, subject=%s\n", 
-                                *      __FUNCTION__, tny_account_get_id (priv->account), 
-                                * tny_header_get_subject (header));
-                                */
                                 
                                /* Apply per-message size limits */
                                if (tny_header_get_message_size (header) < info->max_size)
@@ -970,8 +966,13 @@ update_account_thread (gpointer thr_user_data)
                                tny_iterator_next (iter);
                        }
                        g_object_unref (iter);
+               } else {
+                       /* We do not need to do it the first time
+                          because it's automatically done by the tree
+                          model */
+                       if (G_UNLIKELY (!first_time))
+                               tny_folder_poke_status (TNY_FOLDER (folder));
                }
-               
                tny_folder_remove_observer (TNY_FOLDER (folder), TNY_FOLDER_OBSERVER (observer));
                g_object_unref (observer);
                observer = NULL;
@@ -999,7 +1000,7 @@ update_account_thread (gpointer thr_user_data)
                 * user to download them all,
                 * as per the UI spec "Retrieval Limits" section in 4.4: 
                 */
-               printf ("DEBUG: %s: account=%s, len=%d, retrieve_limit = %d\n", __FUNCTION__, 
+               printf ("************************** DEBUG: %s: account=%s, len=%d, retrieve_limit = %d\n", __FUNCTION__, 
                        tny_account_get_id (priv->account), new_headers->len, info->retrieve_limit);
                if (new_headers->len > info->retrieve_limit) {
                        /* TODO: Ask the user, instead of just failing, showing mail_nc_msg_count_limit_exceeded, 
index 44a3505..e0dc501 100644 (file)
@@ -115,6 +115,11 @@ main (int argc, char *argv[])
                { NULL, 0, 0, 0, NULL, NULL, NULL }
        };
 
+       /* Enable threads before anything else, to prevent memory corruption */
+       if (!g_thread_supported())
+               g_thread_init(NULL);
+       gdk_threads_init ();
+
        context = g_option_context_new (NULL);
        g_option_context_add_main_entries (context, options, NULL);