* adding some precondition checks, hopefully adding some stability.
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Mon, 21 Jan 2008 15:04:57 +0000 (15:04 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Mon, 21 Jan 2008 15:04:57 +0000 (15:04 +0000)
  with permission from senor Villar

pmo-trunk-r4070

src/maemo/modest-main-window.c
src/maemo/modest-platform.c
src/modest-mail-operation.c
src/modest-tny-account-store.c
src/modest-ui-actions.c

index a39c31a..3d1b31b 100644 (file)
@@ -2694,6 +2694,8 @@ modest_main_window_screen_is_on (ModestMainWindow *self)
 {
        ModestMainWindowPrivate *priv = NULL;
 
+       g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(self), FALSE);
+
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE (self);
        
        return (priv->display_state == OSSO_DISPLAY_ON) ? TRUE : FALSE;
index 3ff9177..f34538c 100644 (file)
@@ -1342,6 +1342,13 @@ modest_platform_on_new_headers_received (TnyList *header_list,
 {
        gboolean play_sound;
 
+       g_return_if_fail (TNY_IS_LIST(header_list));
+
+       if (tny_list_get_length(header_list) == 0) {
+               g_warning ("%s: header list is empty", __FUNCTION__);
+               return;
+       }
+       
        /* Check whether or not we should play a sound */
        play_sound = modest_conf_get_bool (modest_runtime_get_conf (),
                                           MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
index f425061..522997a 100644 (file)
@@ -706,6 +706,11 @@ send_mail_error_happened_handler (TnySendQueue *queue, TnyHeader *header, TnyMsg
        SendMsgInfo *info = (SendMsgInfo *) userdata;
        TnyHeader *hdr1, *hdr2;
        const char *msgid1, *msgid2;
+
+       if (!TNY_IS_MSG(msg)) {
+               g_warning ("%s: did not receive a valid msg", __FUNCTION__);
+               return;
+       }
        
        hdr1 = tny_msg_get_header(msg);
        hdr2 = tny_msg_get_header(info->msg);
index 2bdb4eb..2dd83d0 100644 (file)
 #include <string.h>
 #include <glib/gi18n.h>
 
+#include <tny-error.h>
 #include <tny-account.h>
 #include <tny-account-store.h>
 #include <tny-store-account.h>
-#include <tny-error.h>
 #include <tny-transport-account.h>
 #include <tny-simple-list.h>
 #include <tny-account-store.h>
@@ -1199,14 +1199,25 @@ get_tny_account_by (TnyList *accounts,
        gboolean found = FALSE;
        TnyAccount *retval = NULL;
 
-       g_return_val_if_fail (accounts && TNY_IS_LIST(accounts), NULL);
+       g_return_val_if_fail (TNY_IS_LIST(accounts), NULL);
 
+       if (tny_list_get_length(accounts) == 0) {
+               g_warning ("%s: account list is empty", __FUNCTION__);
+               return NULL;
+       }
+       
        iter = tny_list_create_iterator (accounts);
        while (!tny_iterator_is_done (iter) && !found) {
                TnyAccount *tmp_account = NULL;
                const gchar *val = NULL;
 
                tmp_account = TNY_ACCOUNT (tny_iterator_get_current (iter));
+               if (!TNY_IS_ACCOUNT(tmp_account)) {
+                       g_warning ("%s: not a valid account", __FUNCTION__);
+                       tmp_account = NULL;
+                       break;
+               }
+
                switch (type) {
                case MODEST_TNY_ACCOUNT_STORE_QUERY_ID:
                        val = tny_account_get_id (tmp_account);
@@ -1221,7 +1232,7 @@ get_tny_account_by (TnyList *accounts,
                        retval = g_object_ref (tmp_account);
                        found = TRUE;
                } else {
-                       if (strcmp (val, str) == 0) {
+                       if (val && str && strcmp (val, str) == 0) {
                                retval = g_object_ref (tmp_account);
                                found = TRUE;
                        }
index fd84c02..d495f70 100644 (file)
@@ -1674,7 +1674,7 @@ new_messages_arrived (ModestMailOperation *self,
           send&receive was invoked by the user then do not show any
           visual notification, only play a sound and activate the LED
           (for the Maemo version) */
-       if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0))
+       if (TNY_IS_LIST(new_headers) && (tny_list_get_length (new_headers)) > 0)
                modest_platform_on_new_headers_received (new_headers, 
                                                         show_visual_notifications);