Check for attributes being available before querying them
GLib 2.75 started checking if a GFileInfo was created with the attribute we're querying, instead of failing silently and leaving us in an inconsistent state. Turns out that GtkFileChooserWidget, GtkFileSystemModel, and GtkPathBar trip the newly introduced check.
This commit is contained in:
@@ -3549,9 +3549,12 @@ show_and_select_files (GtkFileChooserWidget *impl,
|
||||
|
||||
if (!g_file_info_get_attribute_boolean (info, "filechooser::visible"))
|
||||
{
|
||||
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 &&
|
||||
(g_file_info_get_is_hidden (info) ||
|
||||
g_file_info_get_is_backup (info)))
|
||||
((has_is_hidden && g_file_info_get_is_hidden (info)) ||
|
||||
(has_is_backup && g_file_info_get_is_backup (info))))
|
||||
{
|
||||
set_show_hidden (impl, TRUE);
|
||||
enabled_hidden = TRUE;
|
||||
|
||||
@@ -209,13 +209,18 @@ node_should_be_visible (GtkFileSystemModel *model,
|
||||
gboolean filtered_out)
|
||||
{
|
||||
FileModelNode *node = get_node (model, id);
|
||||
gboolean has_is_hidden;
|
||||
gboolean has_is_backup;
|
||||
gboolean result;
|
||||
|
||||
if (node->info == NULL)
|
||||
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 &&
|
||||
(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;
|
||||
|
||||
if (_gtk_file_info_consider_as_directory (node->info))
|
||||
|
||||
@@ -776,6 +776,7 @@ gtk_path_bar_get_info_callback (GObject *source,
|
||||
GFileInfo *info;
|
||||
ButtonData *button_data;
|
||||
const char *display_name;
|
||||
gboolean has_is_hidden, has_is_backup;
|
||||
gboolean is_hidden;
|
||||
|
||||
info = g_file_query_info_finish (file, result, NULL);
|
||||
@@ -794,7 +795,10 @@ gtk_path_bar_get_info_callback (GObject *source,
|
||||
file_info->cancellable = NULL;
|
||||
|
||||
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);
|
||||
has_is_hidden = g_file_info_has_attribute (info, "standard::is-hidden");
|
||||
has_is_backup = g_file_info_has_attribute (info, "standard::is-backup");
|
||||
is_hidden = (has_is_hidden && g_file_info_get_is_hidden (info)) ||
|
||||
(has_is_backup && g_file_info_get_is_backup (info));
|
||||
|
||||
button_data = make_directory_button (file_info->path_bar, display_name,
|
||||
file_info->file,
|
||||
|
||||
Reference in New Issue
Block a user