Updating branch refs/heads/master to 3fe1a1a2fa0eebc7c443d80316de1ad695cb2f75 (commit) from 6d1c8e9e08f86d0b206ce86f899c8b89ed4e239e (commit)
commit 3fe1a1a2fa0eebc7c443d80316de1ad695cb2f75 Author: Stephan Arts <step...@xfce.org> Date: Wed Feb 22 17:50:31 2012 +0100 Fix memory leak and improve thumbnailing performance src/file.c | 13 ++++++++ src/icon_bar.c | 87 ++++++++++++++++------------------------------------- src/thumbnailer.c | 31 +++++++++++------- 3 files changed, 58 insertions(+), 73 deletions(-) diff --git a/src/file.c b/src/file.c index 13e5df3..4cc68ad 100644 --- a/src/file.c +++ b/src/file.c @@ -28,6 +28,7 @@ #include "util.h" #include "file.h" +#include "thumbnailer.h" static void rstto_file_init (GObject *); @@ -454,12 +455,22 @@ const GdkPixbuf * rstto_file_get_thumbnail ( RsttoFile *file , RsttoThumbnailSize size) { const gchar *thumbnail_path; + RsttoThumbnailer *thumbnailer; if (file->priv->thumbnails[size]) return file->priv->thumbnails[size]; thumbnail_path = rstto_file_get_thumbnail_path (file); + thumbnailer = rstto_thumbnailer_new(); + rstto_thumbnailer_queue_file (thumbnailer, file); + + /* FIXME: + * + * The thumbnail should be updated on the "ready" signal + * of the thumbnailer, to account for changed thumbnails + * aswell as missing ones. + */ file->priv->thumbnails[size] = gdk_pixbuf_new_from_file_at_scale ( thumbnail_path, rstto_thumbnail_size[size], @@ -467,5 +478,7 @@ rstto_file_get_thumbnail ( RsttoFile *file , RsttoThumbnailSize size) TRUE, NULL); + g_object_unref (thumbnailer); + return file->priv->thumbnails[size]; } diff --git a/src/icon_bar.c b/src/icon_bar.c index 500ea2e..3d6eca2 100644 --- a/src/icon_bar.c +++ b/src/icon_bar.c @@ -1,7 +1,9 @@ /*- * Copyright (c) 2004-2006 os-cillation e.K. + * Copyright (c) 2012 Stephan Arts <step...@xfce.org> * * Written by Benedikt Meurer <be...@xfce.org>. + * Modified by Stephan Arts <step...@xfce.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -38,65 +40,18 @@ #include "marshal.h" #include "icon_bar.h" -/** - * SECTION: rstto-icon-bar - * @title: RsttoIconBar - * @short_description: A widget for displaying icon bars - * @include: rstto/rstto.h - * @see_also: <ulink url="http://library.gnome.org/devel/gtk/stable/GtkTreeModel.html"> - * GtkTreeModel</ulink>, - * <ulink url="http://library.gnome.org/devel/gtk/stable/TreeWidget.html"> - * Tree and List Widget Overview</ulink> - * - * A widget that displays any object that implements the #GtkTreeModel interface - * in an icon bar. - * - * <example> - * <title> - * Creating a new <structname>RsttoIconBar</structname> with a <structname>GtkListStore</structname> - * </title> - * <programlisting> - * enum - * { - * PIXBUF_COLUMN, - * STRING_COLUMN, - * N_COLUMNS, - * }; - * - * { - * GtkListStore *store; - * GtkWidget *bar; - * - * // make a new list store - * store = gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); - * - * // fill the store with data - * fill_store (store); - * - * // create the icon bar - * bar = rstto_icon_bar_new_with_model (GTK_TREE_MODEL (store)); - * rstto_icon_bar_set_pixbuf_column (RSTTO_ICON_BAR (bar), PIXBUF_COLUMN); - * rstto_icon_bar_set_file_column (RSTTO_ICON_BAR (bar), FILE_COLUMN); - * gtk_widget_show (bar); - * - * // the icon bar keeps a reference on the store now - * g_object_unref (G_OBJECT (store)); - * - * // add the bar to your GUI now... - * } - * </programlisting> - * </example> - **/ - - - #define MINIMUM_ICON_ITEM_WIDTH 32 #define ICON_TEXT_PADDING 1 -#define RSTTO_ICON_BAR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), RSTTO_TYPE_ICON_BAR, RsttoIconBarPrivate)) +#define RSTTO_ICON_BAR_GET_PRIVATE(obj) ( \ + G_TYPE_INSTANCE_GET_PRIVATE ( \ + (obj), \ + RSTTO_TYPE_ICON_BAR, \ + RsttoIconBarPrivate)) -#define RSTTO_ICON_BAR_VALID_MODEL_AND_COLUMNS(obj) ((obj)->priv->model != NULL && \ - (obj)->priv->file_column != -1) +#define RSTTO_ICON_BAR_VALID_MODEL_AND_COLUMNS(obj) \ + ((obj)->priv->model != NULL && \ + (obj)->priv->file_column != -1) @@ -879,7 +834,11 @@ rstto_icon_bar_size_allocate ( if (icon_bar->priv->auto_center == TRUE) { if (icon_bar->priv->active_item) - value = icon_bar->priv->active_item->index * icon_bar->priv->item_height - ((page_size-icon_bar->priv->item_height)/2); + { + value = icon_bar->priv->active_item->index * icon_bar->priv->item_height;// - ((page_size-icon_bar->priv->item_height)/2); + g_debug("V: %f", value); + } + if (value > (gtk_adjustment_get_upper (icon_bar->priv->vadjustment)-page_size)) value = (gtk_adjustment_get_upper (icon_bar->priv->vadjustment)-page_size); @@ -967,19 +926,19 @@ rstto_icon_bar_expose ( area.width = icon_bar->priv->item_width; area.height = icon_bar->priv->item_height; - iter = item->iter; - gtk_tree_model_get (icon_bar->priv->model, &iter, - icon_bar->priv->file_column, &file, - -1); if (gdk_region_rect_in (expose->region, &area) != GDK_OVERLAP_RECTANGLE_OUT) { - rstto_thumbnailer_queue_file (icon_bar->priv->thumbnailer, file); rstto_icon_bar_paint_item (icon_bar, item, &expose->area); } else { + iter = item->iter; + gtk_tree_model_get (icon_bar->priv->model, &iter, + icon_bar->priv->file_column, &file, + -1); rstto_thumbnailer_dequeue_file (icon_bar->priv->thumbnailer, file); + g_object_unref (file); } } @@ -1029,6 +988,7 @@ rstto_icon_bar_motion ( gtk_tree_model_get (icon_bar->priv->model, &iter, icon_bar->priv->file_column, &file, -1); + g_object_unref (file); gtk_widget_trigger_tooltip_query (widget); } @@ -1302,6 +1262,8 @@ rstto_icon_bar_paint_item ( pixbuf = rstto_file_get_thumbnail (file, icon_bar->priv->thumbnail_size); + g_object_unref (file); + if (NULL == pixbuf) { pixbuf = thumbnail_missing; @@ -2175,6 +2137,7 @@ cb_rstto_thumbnail_size_changed ( { GValue val_thumbnail_size = { 0, }; RsttoIconBar *icon_bar = RSTTO_ICON_BAR (user_data); + gboolean auto_center = icon_bar->priv->auto_center; g_value_init (&val_thumbnail_size, G_TYPE_UINT); @@ -2183,11 +2146,13 @@ cb_rstto_thumbnail_size_changed ( "thumbnail-size", &val_thumbnail_size); + icon_bar->priv->thumbnail_size = g_value_get_uint (&val_thumbnail_size); rstto_icon_bar_invalidate (icon_bar); rstto_icon_bar_update_missing_icon (icon_bar); + icon_bar->priv->auto_center = auto_center; } diff --git a/src/thumbnailer.c b/src/thumbnailer.c index 01f69d7..06d4312 100644 --- a/src/thumbnailer.c +++ b/src/thumbnailer.c @@ -359,17 +359,21 @@ rstto_thumbnailer_dequeue_file ( if (thumbnailer->priv->request_timer_id) { g_source_remove (thumbnailer->priv->request_timer_id); - if (thumbnailer->priv->handle) + } + + if (thumbnailer->priv->handle) + { + if(dbus_g_proxy_call(thumbnailer->priv->proxy, + "Dequeue", + NULL, + G_TYPE_UINT, thumbnailer->priv->handle, + G_TYPE_INVALID) == FALSE) { - if(dbus_g_proxy_call(thumbnailer->priv->proxy, - "Dequeue", - NULL, - G_TYPE_UINT, thumbnailer->priv->handle, - G_TYPE_INVALID) == FALSE) - { - } - thumbnailer->priv->handle = 0; } + thumbnailer->priv->handle = 0; + g_slist_foreach (thumbnailer->priv->in_process_queue, (GFunc)g_object_unref, NULL); + g_slist_free (thumbnailer->priv->in_process_queue); + thumbnailer->priv->in_process_queue = NULL; } if (g_slist_find (thumbnailer->priv->queue, file) != NULL) @@ -502,9 +506,12 @@ cb_rstto_thumbnailer_request_finished ( g_return_if_fail ( RSTTO_IS_THUMBNAILER (thumbnailer) ); - g_slist_foreach (thumbnailer->priv->in_process_queue, (GFunc)g_object_unref, NULL); - g_slist_free (thumbnailer->priv->in_process_queue); - thumbnailer->priv->in_process_queue = NULL; + if (thumbnailer->priv->in_process_queue) + { + g_slist_foreach (thumbnailer->priv->in_process_queue, (GFunc)g_object_unref, NULL); + g_slist_free (thumbnailer->priv->in_process_queue); + thumbnailer->priv->in_process_queue = NULL; + } } static void _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits