From a6597f754279d3387f19d58fce1351cc9ec86c1d Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Tue, 25 Mar 2008 10:43:10 +0000 Subject: [PATCH] * Fixes NB#82971, do not crash if we don't find a SendInfo structure when a send error happens pmo-trunk-r4340 --- src/modest-tny-send-queue.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/modest-tny-send-queue.c b/src/modest-tny-send-queue.c index fbeb4c7..fc77575 100644 --- a/src/modest-tny-send-queue.c +++ b/src/modest-tny-send-queue.c @@ -210,7 +210,10 @@ _on_added_to_outbox (TnySendQueue *self, header = tny_msg_get_header (msg); msg_id = modest_tny_send_queue_get_msg_id (header); - g_return_if_fail(msg_id != NULL); + if (!msg_id) { + g_warning ("%s: No msg_id returned for header", __FUNCTION__); + goto end; + } /* Put newly added message in WAITING state */ existing = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE(self), msg_id); @@ -226,7 +229,8 @@ _on_added_to_outbox (TnySendQueue *self, g_signal_emit (self, signals[STATUS_CHANGED_SIGNAL], 0, info->msg_id, info->status); - g_object_unref(G_OBJECT(header)); + end: + g_object_unref (G_OBJECT(header)); } static void @@ -603,7 +607,7 @@ _on_msg_error_happened (TnySendQueue *self, generic send queue errors with this signal as well, and those notifications are not bound to any particular header or message */ - if (header) { + if (header && TNY_IS_HEADER (header)) { SendInfo *info = NULL; GList *item = NULL; gchar* msg_uid = NULL; @@ -611,7 +615,16 @@ _on_msg_error_happened (TnySendQueue *self, /* Get sending info (create new if it doesn not exist) */ msg_uid = modest_tny_send_queue_get_msg_id (header); item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), - msg_uid); + msg_uid); + + /* TODO: this should not happen (but it does), so the + problem should be located in the way we generate + the message uids */ + if (!item) { + g_warning ("%s: could not find item with id '%s'", __FUNCTION__, msg_uid); + g_free(msg_uid); + return; + } info = item->data; -- 1.7.9.5