diff options
author | Valentin Blot <14005-vblot@users.noreply.gitlab.gnome.org> | 2022-12-05 12:40:35 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@dfupdate.se> | 2022-12-05 21:17:21 +0100 |
commit | f50ab26d22735b3813325098cedd0e03474674d9 (patch) | |
tree | eacc3198f8e9972c723e67d91b364a815910d421 | |
parent | e4d338c48cc0c2c416e8e7cd66ea707d520d197f (diff) | |
download | gnome-maps-f50ab26d22735b3813325098cedd0e03474674d9.tar.gz |
file-data-source: Check for error on file retrieval
On local data sources, sometimes file read operations are cancelled.
When such a thing arises, empty data is passed to "received-data"
signal, leading to a warning in shumate: "Failed to create texture
from tile data: Unrecognized image file format", and a crash of
gnome-maps. We add a check on the result of
g_file_load_contents_finish and if there is an error we emit a
warning and we do not send the "received-data" signal.
-rw-r--r-- | lib/maps-file-data-source.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/maps-file-data-source.c b/lib/maps-file-data-source.c index 40a3f91b..73f87556 100644 --- a/lib/maps-file-data-source.c +++ b/lib/maps-file-data-source.c @@ -467,11 +467,18 @@ on_file_load (GObject *source_object, gpointer user_data) { g_autoptr(GTask) task = user_data; + g_autoptr(GError) error = NULL; FillTileData *data = g_task_get_task_data (task); char *contents; gsize length; - g_file_load_contents_finish (data->file, res, &contents, &length, NULL, NULL); + g_file_load_contents_finish (data->file, res, &contents, &length, NULL, &error); + + if (error) + { + g_warning ("Failed to load file: %s", error->message); + return; + } if (contents != NULL) { |