Check for attribute availability before accessing it
Starting from GLib 2.76, the standard attribute getters in the GFileInfo object will warn if the attribute is unset, instead of silently bailing out and returning a default value.
This commit is contained in:
@ -4634,10 +4634,12 @@ show_and_select_files (GtkFileChooserWidget *impl,
|
|||||||
if (!_gtk_file_system_model_iter_is_visible (fsmodel, &iter))
|
if (!_gtk_file_system_model_iter_is_visible (fsmodel, &iter))
|
||||||
{
|
{
|
||||||
GFileInfo *info = _gtk_file_system_model_get_info (fsmodel, &iter);
|
GFileInfo *info = _gtk_file_system_model_get_info (fsmodel, &iter);
|
||||||
|
gboolean has_is_hidden = g_file_info_has_attribute (info, "standard::is-hidden");
|
||||||
|
gboolean has_is_backup = g_file_info_has_attribute (info, "standard::is-backup");
|
||||||
|
|
||||||
if (!enabled_hidden &&
|
if (!enabled_hidden &&
|
||||||
(g_file_info_get_is_hidden (info) ||
|
((has_is_hidden && g_file_info_get_is_hidden (info)) ||
|
||||||
g_file_info_get_is_backup (info)))
|
(has_is_backup && g_file_info_get_is_backup (info))))
|
||||||
{
|
{
|
||||||
g_object_set (impl, "show-hidden", TRUE, NULL);
|
g_object_set (impl, "show-hidden", TRUE, NULL);
|
||||||
enabled_hidden = TRUE;
|
enabled_hidden = TRUE;
|
||||||
|
|||||||
@ -442,16 +442,23 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
node_should_be_visible (GtkFileSystemModel *model, guint id, gboolean filtered_out)
|
node_should_be_visible (GtkFileSystemModel *model,
|
||||||
|
guint id,
|
||||||
|
gboolean filtered_out)
|
||||||
{
|
{
|
||||||
FileModelNode *node = get_node (model, id);
|
FileModelNode *node = get_node (model, id);
|
||||||
|
gboolean has_is_hidden, has_is_backup;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if (node->info == NULL)
|
if (node->info == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
has_is_hidden = g_file_info_has_attribute (node->info, "standard::is-hidden");
|
||||||
|
has_is_backup = g_file_info_has_attribute (node->info, "standard::is-backup");
|
||||||
|
|
||||||
if (!model->show_hidden &&
|
if (!model->show_hidden &&
|
||||||
(g_file_info_get_is_hidden (node->info) || g_file_info_get_is_backup (node->info)))
|
((has_is_hidden && g_file_info_get_is_hidden (node->info)) ||
|
||||||
|
(has_is_backup && g_file_info_get_is_backup (node->info))))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (_gtk_file_info_consider_as_directory (node->info))
|
if (_gtk_file_info_consider_as_directory (node->info))
|
||||||
|
|||||||
@ -1762,7 +1762,8 @@ gtk_path_bar_get_info_callback (GCancellable *cancellable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
display_name = g_file_info_get_display_name (info);
|
display_name = g_file_info_get_display_name (info);
|
||||||
is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
|
is_hidden = g_file_info_get_attribute_boolean (info, "standard::is-hidden") ||
|
||||||
|
g_file_info_get_attribute_boolean (info, "standard::is-backup");
|
||||||
|
|
||||||
button_data = make_directory_button (file_info->path_bar, display_name,
|
button_data = make_directory_button (file_info->path_bar, display_name,
|
||||||
file_info->file,
|
file_info->file,
|
||||||
|
|||||||
Reference in New Issue
Block a user