Merge branch 'wip/hadess/fix-remote-filechooser-main' into 'master'

Fix crasher/warnings when browsing remote filesystems

Closes #2482

See merge request GNOME/gtk!1490
This commit is contained in:
Bastien Nocera 2020-03-13 12:36:10 +00:00
commit 179b39eb86
2 changed files with 11 additions and 1 deletions

View File

@ -393,7 +393,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
#define MODEL_ATTRIBUTES "standard::name,standard::type,standard::display-name," \
"standard::is-hidden,standard::is-backup,standard::size," \
"standard::content-type,time::modified,time::access," \
"standard::content-type,standard::fast-content-type,time::modified,time::access," \
"access::can-rename,access::can-delete,access::can-trash," \
"standard::target-uri"
enum {
@ -4567,6 +4567,11 @@ get_type_information (GtkFileChooserWidget *impl,
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
content_type = g_file_info_get_content_type (info);
if (!content_type)
content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
if (!content_type)
goto end;
switch (priv->type_format)
{
case TYPE_FORMAT_MIME:
@ -4584,6 +4589,7 @@ get_type_information (GtkFileChooserWidget *impl,
g_assert_not_reached ();
}
end:
return g_strdup ("");
}

View File

@ -397,6 +397,10 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
if (required & GTK_FILE_FILTER_MIME_TYPE)
{
const char *s = g_file_info_get_content_type (node->info);
if (!s)
s = g_file_info_get_attribute_string (node->info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
if (s)
{
mime_type = g_content_type_get_mime_type (s);