filedialog: Don't assert too much

The GtkFileDialog code was asserting that
we get exactly one file back. But the function
is nullable anyway, so lets just return NULL
if we don't have a file.

Fixes: #5975
This commit is contained in:
Matthias Clasen 2023-07-23 12:30:38 -04:00
parent 0b1bcf8bee
commit 79721d64ad

View File

@ -887,11 +887,11 @@ finish_file_op (GtkFileDialog *self,
files = g_task_propagate_pointer (task, error);
if (files)
{
GFile *file;
GFile *file = NULL;
g_assert (g_list_model_get_n_items (files) == 1);
if (g_list_model_get_n_items (files) > 0)
file = g_list_model_get_item (files, 0);
file = g_list_model_get_item (files, 0);
g_object_unref (files);
return file;