There is a memory use problem in nautilus: https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/204413
On larger zoom levels we read the actual image files to use as thumbnails. However, we forgot to check that the file is an image before we do this, so we can accidentally start loading other types of files too. This is especially problematic since the thumbnail size limit only affects images, so these may be large files. Its not exactly a leak, as the memory will eventually be freed, but for very large files it can be a problem anyway. Fix attached.
>From b3baab38d95cad88590ea7e5d16956a345b4544c Mon Sep 17 00:00:00 2001 From: Alexander Larsson <al...@redhat.com> Date: Fri, 18 Sep 2009 11:05:44 +0200 Subject: [PATCH] Don't load files for thumbnailing that we can't thumbnail anyway When zooming out we read the real image and use that as the thumbnail. However, we should only do this for files gdk-pixbuf can read as other things can't be read anyway and may potentially be very large (such as videos) since the thumbnail size limit only applies for images. --- libnautilus-private/nautilus-file.c | 3 +- libnautilus-private/nautilus-thumbnails.c | 30 +++++++++++++++++++++++----- libnautilus-private/nautilus-thumbnails.h | 1 + 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 0f0751f..7dd6c94 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -4181,7 +4181,8 @@ nautilus_file_get_icon (NautilusFile *file, since the zoom level 150% gives thumbnails at 144, which is ok to scale up from 128. */ if (modified_size > 128*1.25 && - !file->details->thumbnail_wants_original) { + !file->details->thumbnail_wants_original && + nautilus_can_thumbnail_internally (file)) { /* Invalidate if we resize upward */ file->details->thumbnail_wants_original = TRUE; nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL); diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c index 382f8c0..df9b438 100644 --- a/libnautilus-private/nautilus-thumbnails.c +++ b/libnautilus-private/nautilus-thumbnails.c @@ -770,17 +770,35 @@ get_types_table (void) return image_mime_types; } -gboolean -nautilus_thumbnail_is_mimetype_limited_by_size (const char *mime_type) +static gboolean +pixbuf_can_load_type (const char *mime_type) { GHashTable *image_mime_types; - + image_mime_types = get_types_table (); - if (g_hash_table_lookup (image_mime_types, mime_type)) { - return TRUE; + if (g_hash_table_lookup (image_mime_types, mime_type)) { + return TRUE; } - return FALSE; + return FALSE; +} + +gboolean +nautilus_can_thumbnail_internally (NautilusFile *file) +{ + char *mime_type; + gboolean res; + + mime_type = nautilus_file_get_mime_type (file); + res = pixbuf_can_load_type (mime_type); + g_free (mime_type); + return res; +} + +gboolean +nautilus_thumbnail_is_mimetype_limited_by_size (const char *mime_type) +{ + return pixbuf_can_load_type (mime_type); } gboolean diff --git a/libnautilus-private/nautilus-thumbnails.h b/libnautilus-private/nautilus-thumbnails.h index bfe0724..6128eb3 100644 --- a/libnautilus-private/nautilus-thumbnails.h +++ b/libnautilus-private/nautilus-thumbnails.h @@ -46,6 +46,7 @@ typedef void (* NautilusThumbnailAsyncLoadFunc) (NautilusThumbnailAsyncLoadHandl /* Returns NULL if there's no thumbnail yet. */ void nautilus_create_thumbnail (NautilusFile *file); gboolean nautilus_can_thumbnail (NautilusFile *file); +gboolean nautilus_can_thumbnail_internally (NautilusFile *file); gboolean nautilus_thumbnail_is_mimetype_limited_by_size (const char *mime_type); void nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf); -- 1.6.2.5
-- nautilus-list mailing list nautilus-list@gnome.org http://mail.gnome.org/mailman/listinfo/nautilus-list