[maemo-commits] [maemo-commits] r13093 - in projects/haf/tags/hildon-thumbnail/0.12: . thumbs
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Aug 10 11:14:27 EEST 2007
- Previous message: [maemo-commits] r13092 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
- Next message: [maemo-commits] r13094 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2007-08-10 11:14:26 +0300 (Fri, 10 Aug 2007) New Revision: 13093 Modified: projects/haf/tags/hildon-thumbnail/0.12/ChangeLog projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c Log: patched Modified: projects/haf/tags/hildon-thumbnail/0.12/ChangeLog =================================================================== --- projects/haf/tags/hildon-thumbnail/0.12/ChangeLog 2007-08-10 07:11:23 UTC (rev 13092) +++ projects/haf/tags/hildon-thumbnail/0.12/ChangeLog 2007-08-10 08:14:26 UTC (rev 13093) @@ -1,3 +1,12 @@ +2007-08-10 Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> + + Patch from Daniil Ivanov: + * thumbs/thumber-gdk-pixbuf.c: Add global variable 'oom'. + (create_thumb): Check OOM condition from the 'oom' variable. + (thumbnailer_oom_func): New. + (main): Register thumbnailer_oom_func as the OOM callback. + Fixes: NB#63712 + 2006-10-13 Marius Vollmer <marius.vollmer at nokia.com> Released 0.8-1. @@ -22,9 +31,9 @@ 2005-10-12 Luc Pionchon <luc.pionchon at nokia.com> - N#20238 - Thumbnailer causes system crashes on large images + N#20238 - Thumbnailer causes system crashes on large images - * thumbs/thumber-gdk-pixbuf.c + * thumbs/thumber-gdk-pixbuf.c (can_crop_file): Removed artificial resolution restriction, since more precice memory monitoring can be used now. Modified: projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c =================================================================== --- projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c 2007-08-10 07:11:23 UTC (rev 13092) +++ projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c 2007-08-10 08:14:26 UTC (rev 13093) @@ -1,7 +1,7 @@ /* * This file is part of osso-thumbnail package * - * Copyright (C) 2005, 2006 Nokia Corporation. All rights reserved. + * Copyright (C) 2005-2007 Nokia Corporation. All rights reserved. * * Contact: Marius Vollmer <marius.vollmer at nokia.com> * @@ -32,6 +32,8 @@ #include <stdio.h> #include <gdk-pixbuf/gdk-pixbuf.h> +static gboolean oom = FALSE; + GdkPixbuf *crop_resize(GdkPixbuf *src, int width, int height) { int x = width, y = height; int a = gdk_pixbuf_get_width(src); @@ -72,8 +74,6 @@ v = b; } - //printf("na=%f, nb=%f, nx=%d, ny=%d, u=%d, v=%d\n", na, nb, nx, ny, u, v); - if(a * y < b * x) { nb = (double)a * v / u; // Center @@ -91,13 +91,6 @@ offx = -offx * scax; offy = -offy * scay; - /* - printf("(%d, %d) -> (%d, %d) => (%f, %f) -> (%d, %d)\n", - a, b, x, y, na, nb, nx, ny); - printf("offx=%f, offy=%f, scax=%f, scay=%f\n", - offx, offy, scax, scay); - */ - dest = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(src), gdk_pixbuf_get_has_alpha(src), gdk_pixbuf_get_bits_per_sample(src), nx, ny); @@ -150,7 +143,7 @@ GdkPixbufLoader *loader; guchar buffer[2048]; FILE *f; - size_t bytes_read; + size_t bytes_read = sizeof(buffer); size_t desired_max_area; f = fopen(local_file, "r"); @@ -161,7 +154,7 @@ g_signal_connect(loader, "size-prepared", G_CALLBACK(size_prepared), GINT_TO_POINTER(desired_max_area)); - do + while (!oom && bytes_read >= sizeof(buffer)) { bytes_read = fread(buffer, 1, sizeof(buffer), f); if (!gdk_pixbuf_loader_write(loader, buffer, bytes_read, error)) @@ -169,7 +162,7 @@ gdk_pixbuf_loader_close(loader, NULL); goto cleanup; } - } while (bytes_read >= sizeof(buffer)); + } if (!gdk_pixbuf_loader_close(loader, error)) goto cleanup; @@ -177,7 +170,7 @@ /* Loader owns reference to this pixbuf */ pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); - if(pixbuf) + if(pixbuf && !oom) result = crop_resize(pixbuf, width, height); cleanup: fclose(f); @@ -191,23 +184,30 @@ pixbuf = gdk_pixbuf_new_from_file_at_size (local_file, width, height, &error); if (error) { - ULOG_ERR ("can't create thumb: %s", error->message); + ULOG_ERR_F("can't create thumb: %s", error->message); g_error_free (error); } return pixbuf; } - + return NULL; } +static void +thumbnailer_oom_func (size_t cur, size_t max, void *data) +{ + ULOG_DEBUG_F("Memory low: %u of %u!", cur, max); + oom = TRUE; +} + int main(int argc, char **argv) { int result; setpriority(PRIO_PROCESS, getpid(), 10); - result = osso_mem_saw_enable(4 << 20, 64, NULL, NULL); + result = osso_mem_saw_enable(4 << 20, 64, thumbnailer_oom_func, NULL); if (result != 0) - ULOG_ERR ("can't install memory watchdog: code %d\n", result); + ULOG_ERR_F("osso_mem_saw_enable failed with error %d", result); else { result = hildon_thumber_main(&argc, &argv, create_thumb);
- Previous message: [maemo-commits] r13092 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
- Next message: [maemo-commits] r13094 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]