From dd0042f76bb7fd941a70c9d85968d9c2523cdedc Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 19 Jun 2011 23:31:29 +0200 Subject: [PATCH] app: implement error handling in gimp_imagefile_icon_callback() Particularly, don't crash if the async operation got cancelled in dispose(). --- app/core/gimpimagefile.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c index 47d2d1e401..aa2aa37e7d 100644 --- a/app/core/gimpimagefile.c +++ b/app/core/gimpimagefile.c @@ -626,22 +626,41 @@ gimp_imagefile_icon_callback (GObject *source_object, GAsyncResult *result, gpointer data) { - GimpImagefile *imagefile = GIMP_IMAGEFILE (data); - GimpImagefilePrivate *private = GET_PRIVATE (imagefile); - GFile *file = G_FILE (source_object); - GError *error = NULL; + GimpImagefile *imagefile; + GimpImagefilePrivate *private; + GFile *file = G_FILE (source_object); + GError *error = NULL; GFileInfo *file_info; file_info = g_file_query_info_finish (file, result, &error); + if (error) + { + /* we were cancelled from dispose() and the imagefile is + * long gone, bail out + */ + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + { + g_clear_error (&error); + return; + } + +#ifdef GIMP_UNSTABLE + g_printerr ("%s: %s\n", G_STRFUNC, error->message); +#endif + + g_clear_error (&error); + } + + imagefile = GIMP_IMAGEFILE (data); + private = GET_PRIVATE (imagefile); + if (file_info) { private->icon = g_object_ref (g_file_info_get_icon (file_info)); g_object_unref (file_info); } - g_clear_error (&error); - if (private->icon_cancellable) { g_object_unref (private->icon_cancellable);