Work to complete implementation of purge attachments operation
[modest] / src / maemo / modest-msg-edit-window.c
index 1365ded..e6185e3 100644 (file)
@@ -277,10 +277,11 @@ modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
        modest_window_class->zoom_plus_func = modest_msg_edit_window_zoom_plus;
        modest_window_class->zoom_minus_func = modest_msg_edit_window_zoom_minus;
        modest_window_class->show_toolbar_func = modest_msg_edit_window_show_toolbar;
+       modest_window_class->save_state_func = save_state;
 
        g_type_class_add_private (gobject_class, sizeof(ModestMsgEditWindowPrivate));
 
-       modest_window_class->save_state_func = save_state;
+
 }
 
 static void
@@ -530,6 +531,11 @@ modest_msg_edit_window_finalize (GObject *obj)
                priv->system_clipboard_change_handler_id = 0;
        }
        
+       if (priv->draft_msg != NULL) {
+               g_object_unref (priv->draft_msg);
+               priv->draft_msg = NULL;
+       }
+
        /* This had to stay alive for as long as the combobox that used it: */
        modest_pair_list_free (priv->from_field_protos);
        
@@ -658,7 +664,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg)
        update_dimmed (self);
        text_buffer_can_undo (priv->text_buffer, FALSE, self);
 
-       priv->draft_msg = msg;
+       priv->draft_msg = g_object_ref(msg);
 }
 
 static void
@@ -1611,7 +1617,7 @@ modest_msg_edit_window_attach_file_noninteractive (
        
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
 
-       if (file_uri) {
+       if (file_uri && strlen(file_uri)) {
                gint file_id = 0;
                
                /* TODO: We should probably try to use only the URI,
@@ -1619,7 +1625,7 @@ modest_msg_edit_window_attach_file_noninteractive (
                 */
                gchar* filename = g_filename_from_uri (file_uri, NULL, NULL);
                if (!filename) {
-                       g_warning("%s: g_filename_from_uri(%s) failed.\n", __FUNCTION__, file_uri);
+                       g_warning("%s: g_filename_from_uri('%s') failed.\n", __FUNCTION__, file_uri);
                }
 
                file_id = g_open (filename, O_RDONLY, 0);
@@ -2927,3 +2933,5 @@ modest_msg_edit_window_set_sent (ModestMsgEditWindow *window,
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(window);
        priv->sent = sent;
 }
+
+