[evolution/gnome-3-10] Make e_attachment_set_file_info() thread-safe.



commit ed300ba99f6f47230776490dbdd9fdb7427d9f57
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Nov 6 16:02:25 2013 -0500

    Make e_attachment_set_file_info() thread-safe.
    
    Missed this one in commit 9058c6f85dc49f9500e7e67819acfd8c0d2d369c.
    
    (cherry picked from commit 03972535919d96d55a409988f4436e0a5e54b96b)

 e-util/e-attachment.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/e-util/e-attachment.c b/e-util/e-attachment.c
index bad4e0b..f0c00b1 100644
--- a/e-util/e-attachment.c
+++ b/e-util/e-attachment.c
@@ -1338,14 +1338,16 @@ e_attachment_set_file_info (EAttachment *attachment,
        GtkTreeRowReference *reference;
        GIcon *icon;
 
-       reference = e_attachment_get_reference (attachment);
+       g_return_if_fail (E_IS_ATTACHMENT (attachment));
 
-       if (file_info != NULL)
+       if (file_info != NULL) {
+               g_return_if_fail (G_IS_FILE_INFO (file_info));
                g_object_ref (file_info);
+       }
 
-       if (attachment->priv->file_info != NULL)
-               g_object_unref (attachment->priv->file_info);
+       g_mutex_lock (&attachment->priv->property_lock);
 
+       g_clear_object (&attachment->priv->file_info);
        attachment->priv->file_info = file_info;
 
        /* If the GFileInfo contains a GThemedIcon, append a
@@ -1355,9 +1357,12 @@ e_attachment_set_file_info (EAttachment *attachment,
                g_themed_icon_append_name (
                        G_THEMED_ICON (icon), DEFAULT_ICON_NAME);
 
+       g_mutex_unlock (&attachment->priv->property_lock);
+
        g_object_notify (G_OBJECT (attachment), "file-info");
 
        /* Tell the EAttachmentStore its total size changed. */
+       reference = e_attachment_get_reference (attachment);
        if (gtk_tree_row_reference_valid (reference)) {
                GtkTreeModel *model;
                model = gtk_tree_row_reference_get_model (reference);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]