[gthumb/gthumb-2-14] Fixed a memory leak in GthCellRendererThumbnail
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb/gthumb-2-14] Fixed a memory leak in GthCellRendererThumbnail
- Date: Thu, 3 Nov 2011 17:07:14 +0000 (UTC)
commit e56ff6badcc3c480388b0f2ae5825f6e2aabbe05
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Nov 3 17:41:34 2011 +0100
Fixed a memory leak in GthCellRendererThumbnail
gthumb/gth-cell-renderer-thumbnail.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gthumb/gth-cell-renderer-thumbnail.c b/gthumb/gth-cell-renderer-thumbnail.c
index 5b95f68..891ba50 100644
--- a/gthumb/gth-cell-renderer-thumbnail.c
+++ b/gthumb/gth-cell-renderer-thumbnail.c
@@ -135,9 +135,13 @@ gth_cell_renderer_thumbnail_set_property (GObject *object,
self->priv->is_icon = g_value_get_boolean (value);
break;
case PROP_THUMBNAIL:
+ if (self->priv->thumbnail != NULL)
+ g_object_unref (self->priv->thumbnail);
self->priv->thumbnail = g_value_dup_object (value);
break;
case PROP_FILE:
+ if (self->priv->file != NULL)
+ g_object_unref (self->priv->file);
self->priv->file = g_value_dup_object (value);
break;
case PROP_CHECKED:
@@ -254,10 +258,6 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
&thumb_rect.width,
&thumb_rect.height);
- pixbuf = self->priv->thumbnail;
- if (pixbuf == NULL)
- return;
-
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
thumb_rect.x += cell_area->x + xpad;
@@ -273,6 +273,12 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
cr = gdk_cairo_create (window);
+ pixbuf = self->priv->thumbnail;
+ if (pixbuf == NULL)
+ return;
+
+ g_object_ref (pixbuf);
+
image_rect.width = gdk_pixbuf_get_width (pixbuf);
image_rect.height = gdk_pixbuf_get_height (pixbuf);
image_rect.x = thumb_rect.x + (thumb_rect.width - image_rect.width) * .5;
@@ -405,6 +411,7 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
cairo_fill (cr);
_g_object_unref (colorized);
+ g_object_unref (pixbuf);
cairo_destroy (cr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]