Fixed several reference leaks
authorSergio Villar Senín <svillar@igalia.com>
Tue, 5 May 2009 09:37:18 +0000 (11:37 +0200)
committerSergio Villar Senín <svillar@igalia.com>
Tue, 5 May 2009 09:37:18 +0000 (11:37 +0200)
src/hildon2/modest-maemo-utils.c
src/hildon2/modest-msg-edit-window.c
src/hildon2/modest-msg-view-window.c

index f7de85b..dfd2658 100644 (file)
@@ -536,9 +536,10 @@ modest_maemo_utils_select_attachments (GtkWindow *window, TnyList *att_list, gbo
                        gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, filename, 1, part, -1);
                        attachments_added ++;
                        g_free (filename);
-                       g_object_unref (part);
                }
+               g_object_unref (part);
        }
+       g_object_unref (iterator);
 
        selector = GTK_WIDGET (hildon_touch_selector_new ());
        renderer = gtk_cell_renderer_text_new ();
@@ -572,6 +573,9 @@ modest_maemo_utils_select_attachments (GtkWindow *window, TnyList *att_list, gbo
                }
                if (tny_list_get_length (att_list) == 0)
                        result = FALSE;
+
+               g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
+               g_list_free (selected_rows);
        } else {
                result = FALSE;
        }
index 69f2706..368a1d6 100644 (file)
@@ -2636,7 +2636,6 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window,
                        g_object_unref (att_list);
                        return;
                }
-               
        } else {
                g_object_ref (att_list);
        }
@@ -2707,7 +2706,7 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window,
        g_object_unref (att_list);
 
        /* if the last attachment has been removed, focus the Subject: field */
-       if (!modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view))) 
+       if (!modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)))
                gtk_widget_grab_focus (priv->subject_field);
 }
 
index 3d6753d..f61623b 100644 (file)
@@ -2924,7 +2924,7 @@ void
 modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean get_all)
 {
        ModestMsgViewWindowPrivate *priv;
-       TnyList *mime_parts = NULL;
+       TnyList *mime_parts = NULL, *tmp;
        gchar *confirmation_message;
        gint response;
        gint n_attachments;
@@ -2938,17 +2938,20 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean
         * because we don't have selection
         */
        mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
-               
-       /* Remove already purged messages from mime parts list */
-       iter = tny_list_create_iterator (mime_parts);
+
+       /* Remove already purged messages from mime parts list. We use
+          a copy of the list to remove items in the original one */
+       tmp = tny_list_copy (mime_parts);
+       iter = tny_list_create_iterator (tmp);
        while (!tny_iterator_is_done (iter)) {
                TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter));
-               tny_iterator_next (iter);
-               if (tny_mime_part_is_purged (part)) {
+               if (tny_mime_part_is_purged (part))
                        tny_list_remove (mime_parts, (GObject *) part);
-               }
+
                g_object_unref (part);
+               tny_iterator_next (iter);
        }
+       g_object_unref (tmp);
        g_object_unref (iter);
 
        if (!modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, TRUE) ||
@@ -2993,7 +2996,7 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean
        }
 
        priv->purge_timeout = g_timeout_add (2000, show_remove_attachment_information, window);
-       
+
        iter = tny_list_create_iterator (mime_parts);
        while (!tny_iterator_is_done (iter)) {
                TnyMimePart *part;
@@ -3023,8 +3026,6 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean
                g_object_unref (priv->remove_attachment_banner);
                priv->remove_attachment_banner = NULL;
        }
-
-
 }