[gnome-photos] base-item: Cancel gdk_pixbuf_new_from_stream_async during destruction
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-item: Cancel gdk_pixbuf_new_from_stream_async during destruction
- Date: Tue, 5 Apr 2016 09:47:47 +0000 (UTC)
commit 5eead6b0772b0d4d8b2ac60ae41b615956a7697a
Author: Umang Jain <mailumangjain gmail com>
Date: Tue Apr 5 11:42:21 2016 +0200
base-item: Cancel gdk_pixbuf_new_from_stream_async during destruction
https://bugzilla.gnome.org/show_bug.cgi?id=763908
src/photos-base-item.c | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index bcb1120..b3aa3d8 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -572,8 +572,8 @@ photos_base_item_set_failed_icon (PhotosBaseItem *self)
static void
photos_base_item_refresh_thumb_path_pixbuf (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
- PhotosBaseItem *self = PHOTOS_BASE_ITEM (user_data);
- PhotosBaseItemPrivate *priv = self->priv;
+ PhotosBaseItem *self;
+ PhotosBaseItemPrivate *priv;
GApplication *app;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *scaled_pixbuf = NULL;
@@ -585,18 +585,33 @@ photos_base_item_refresh_thumb_path_pixbuf (GObject *source_object, GAsyncResult
pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
if (error != NULL)
{
- GFile *file;
- gchar *uri;
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_error_free (error);
+ goto out;
+ }
+ else
+ {
+ GFile *file;
+ gchar *uri;
- file = G_FILE (g_object_get_data (G_OBJECT (stream), "file"));
- uri = g_file_get_uri (file);
- g_warning ("Unable to create pixbuf from %s: %s", uri, error->message);
+ file = G_FILE (g_object_get_data (G_OBJECT (stream), "file"));
+ uri = g_file_get_uri (file);
+ g_warning ("Unable to create pixbuf from %s: %s", uri, error->message);
+ g_file_delete_async (file, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+ g_free (uri);
+ g_error_free (error);
+ }
+ }
+
+ self = PHOTOS_BASE_ITEM (user_data);
+ priv = self->priv;
+
+ if (pixbuf == NULL)
+ {
priv->failed_thumbnailing = TRUE;
priv->thumb_path = NULL;
- g_file_delete_async (file, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
photos_base_item_set_failed_icon (self);
- g_free (uri);
- g_error_free (error);
goto out;
}
@@ -610,7 +625,6 @@ photos_base_item_refresh_thumb_path_pixbuf (GObject *source_object, GAsyncResult
g_input_stream_close_async (stream, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
g_clear_object (&scaled_pixbuf);
g_clear_object (&pixbuf);
- g_object_unref (self);
}
@@ -641,9 +655,9 @@ photos_base_item_refresh_thumb_path_read (GObject *source_object, GAsyncResult *
g_object_set_data_full (G_OBJECT (stream), "file", g_object_ref (file), g_object_unref);
gdk_pixbuf_new_from_stream_async (G_INPUT_STREAM (stream),
- NULL,
+ priv->cancellable,
photos_base_item_refresh_thumb_path_pixbuf,
- g_object_ref (self));
+ self);
g_object_unref (stream);
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]