[gthumb] Fixed a memory leak in GthCellRendererThumbnail
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Fixed a memory leak in GthCellRendererThumbnail
- Date: Thu, 3 Nov 2011 17:07:24 +0000 (UTC)
commit 6169d4d4a916bff0328755343c93986b38a08075
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 | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gthumb/gth-cell-renderer-thumbnail.c b/gthumb/gth-cell-renderer-thumbnail.c
index 7a4b1ba..360f5d4 100644
--- a/gthumb/gth-cell-renderer-thumbnail.c
+++ b/gthumb/gth-cell-renderer-thumbnail.c
@@ -132,6 +132,8 @@ 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:
@@ -248,10 +250,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;
@@ -262,6 +260,12 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
if (! gdk_rectangle_intersect (cell_area, &thumb_rect, &draw_rect))
return;
+ 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;
@@ -400,6 +404,7 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
}
gtk_style_context_restore (style_context);
+ g_object_unref (pixbuf);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]