* if called at the wrong time, tny_send_queue_get_outbox may return NULL;
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 5 Feb 2008 08:20:42 +0000 (08:20 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 5 Feb 2008 08:20:42 +0000 (08:20 +0000)
  check for this, fixes a crash (NB#80225)

pmo-trunk-r4136

src/modest-mail-operation.c

index 7baff77..7b80ce3 100644 (file)
@@ -1353,9 +1353,14 @@ inbox_refreshed_cb (TnyFolder *inbox,
 
                /* Get outbox folder */
                outbox = tny_send_queue_get_outbox (TNY_SEND_QUEUE (send_queue));
-               num_messages = tny_folder_get_all_count (outbox);
-               g_object_unref (outbox);
-
+               if (outbox) { /* this could fail in some cases */
+                       num_messages = tny_folder_get_all_count (outbox);
+                       g_object_unref (outbox);
+               } else {
+                       g_warning ("%s: could not get outbox", __FUNCTION__);
+                       num_messages = 0;
+               }
+               
                if (num_messages != 0) {
                        /* Send mails */
                        g_object_unref (priv->account);