File evolution-file_info-display-name.patch of Package evolution
From dff149a8b05eefc013f3717c2d805a363b550d92 Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Tue, 11 Jun 2024 17:04:39 +0200
Subject: [PATCH] EAttachment: Check file_info contains display-name before
accessing it
There could be shown a runtime warning about the attachment's file_info
not containing the display-name attribute while the code still tried
to access it, which is considered a bug in the code using glib2 API,
thus verify the attribute is available before accessing it. Also access
it only when needed, not always.
---
src/e-util/e-attachment.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/e-util/e-attachment.c b/src/e-util/e-attachment.c
index 323e544c77..0bf0db6ea4 100644
--- a/src/e-util/e-attachment.c
+++ b/src/e-util/e-attachment.c
@@ -245,7 +245,6 @@ attachment_update_file_info_columns_idle_cb (gpointer weak_ref)
EAttachment *attachment;
GFileInfo *file_info;
const gchar *content_type;
- const gchar *display_name;
gchar *content_desc;
gchar *display_size;
gchar *description;
@@ -265,7 +264,6 @@ attachment_update_file_info_columns_idle_cb (gpointer weak_ref)
goto exit;
content_type = g_file_info_get_content_type (file_info);
- display_name = g_file_info_get_display_name (file_info);
size = g_file_info_get_size (file_info);
content_desc = g_content_type_get_description (content_type);
@@ -273,6 +271,13 @@ attachment_update_file_info_columns_idle_cb (gpointer weak_ref)
description = e_attachment_dup_description (attachment);
if (description == NULL || *description == '\0') {
+ const gchar *display_name;
+
+ if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
+ display_name = g_file_info_get_display_name (file_info);
+ else
+ display_name = "";
+
g_free (description);
description = g_strdup (display_name);
}
--
2.51.0