From: Dirk-Jan C. Binnema Date: Wed, 4 Jul 2007 17:28:27 +0000 (+0000) Subject: * closing ModestMsgEditWindows with attachments no longer crashes modest X-Git-Tag: git_migration_finished~2962 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=e032d937186b378e491002356de885230656ffc3;hp=50fb34902f76cf6f5747dd372980a7b2a188bd75 * closing ModestMsgEditWindows with attachments no longer crashes modest there was some confusion when TnyMimeParts were treated as gchar*s.... Fixes: NB#62598 pmo-trunk-r2576 --- diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 176dd2b..106295c 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -1075,18 +1075,29 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) GList *cursor = priv->attachments; data->attachments = NULL; while (cursor) { + if (!(TNY_IS_MIME_PART(cursor->data))) { + g_warning ("strange data in attachment list"); + continue; + } data->attachments = g_list_append (data->attachments, - g_strdup ((gchar*)cursor->data)); + g_object_ref (cursor->data)); cursor = g_list_next (cursor); } - data->priority_flags = priv->priority_flags; return data; } -/* TODO: We must duplicate this implementation for GNOME and Maemo, but that is unwise. */ + +static void +unref_gobject (GObject *obj, gpointer data) +{ + if (!G_IS_OBJECT(obj)) + return; + g_object_unref (obj); +} + void modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window, MsgData *data) @@ -1108,8 +1119,8 @@ modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window, g_object_unref (data->draft_msg); data->draft_msg = NULL; } - - g_list_foreach (data->attachments, (GFunc)g_free, NULL); + + g_list_foreach (data->attachments, (GFunc)unref_gobject, NULL); g_list_free (data->attachments); g_slice_free (MsgData, data);