[maemo-commits] [maemo-commits] r17807 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Mar 26 12:58:57 EET 2009
Author: pvanhoof
Date: 2009-03-26 12:58:55 +0200 (Thu, 26 Mar 2009)
New Revision: 17807

Modified:
   projects/haf/trunk/hildon-thumbnail/ChangeLog
   projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am
   projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c
Log:
2009-03-26  Philip Van Hoof  <pvanhoof at codeminded.be>

	* daemon/hildon-thumbnail-daemon.c
	* daemon/plugins/gdkpixbuf-png-out-plugin.c
	* daemon/plugins/gdkpixbuf-jpeg-out-plugin.c
	* daemon/Makefile.am: Bugfix for Bug #108103



Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/ChangeLog	2009-03-26 10:06:17 UTC (rev 17806)
+++ projects/haf/trunk/hildon-thumbnail/ChangeLog	2009-03-26 10:58:55 UTC (rev 17807)
@@ -1,5 +1,12 @@
 2009-03-26  Philip Van Hoof  <pvanhoof at codeminded.be>
 
+	* daemon/hildon-thumbnail-daemon.c
+	* daemon/plugins/gdkpixbuf-png-out-plugin.c
+	* daemon/plugins/gdkpixbuf-jpeg-out-plugin.c
+	* daemon/Makefile.am: Bugfix for Bug #108103
+
+2009-03-26  Philip Van Hoof  <pvanhoof at codeminded.be>
+
 	* thumbs/hildon-thumbnail-factory.c
 	* thumbs/hildon-thumbnail-obj.c
 	* thumbs/hildon-albumart-factory.c

Modified: projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am	2009-03-26 10:06:17 UTC (rev 17806)
+++ projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am	2009-03-26 10:58:55 UTC (rev 17807)
@@ -5,6 +5,7 @@
 	$(GLIB_CFLAGS) \
 	$(GMODULE_CFLAGS) \
 	$(GIO_CFLAGS) $(HAL_CFLAGS) \
+	$(LIBOSSO_CFLAGS) \
 	-DTHUMBNAILERS_DIR=\""/usr/share/thumbnailers"\" \
 	-DALBUMARTERS_DIR=\""/usr/share/albumart-providers"\" \
 	-DPLUGINS_DIR=\""$(libdir)/hildon-thumbnailer/plugins"\" \
@@ -66,7 +67,7 @@
 
 hildon_thumbnailerd_LDADD = \
 	$(top_builddir)/daemon/libshared.la \
-	$(DBUS_LIBS) \
+	$(DBUS_LIBS) $(LIBOSSO_LIBS) \
 	$(GLIB_LIBS) \
 	$(GMODULE_LIBS) \
 	$(GIO_LIBS) $(HAL_LIBS)

Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c	2009-03-26 10:06:17 UTC (rev 17806)
+++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c	2009-03-26 10:58:55 UTC (rev 17807)
@@ -26,6 +26,9 @@
 #include <linux/sched.h>
 #include <sched.h>
 
+#include <osso-mem.h>
+#include <osso-log.h>
+
 #ifndef SCHED_IDLE
 #define SCHED_IDLE 5
 #endif
@@ -362,18 +365,25 @@
 	g_free (path);
 }
 
+static void
+thumbnailer_oom_func (size_t cur, size_t max, void *data)
+{
+	exit(1);
+}
 
 int 
 main (int argc, char **argv) 
 {
 	DBusGConnection *connection;
 	GError *error = NULL;
+	int result;
 
-
 #if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD)
 	mallopt (M_MMAP_THRESHOLD, 128 *1024);
 #endif
 
+	result = osso_mem_saw_enable(4 << 20, 64, thumbnailer_oom_func, NULL);
+
 	g_type_init ();
 
 	if (!g_thread_supported ())
@@ -455,6 +465,7 @@
 		g_main_loop_unref (main_loop);
 	}
 
+	osso_mem_saw_disable();
 
 	return 0;
 }

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c	2009-03-26 10:06:17 UTC (rev 17806)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c	2009-03-26 10:58:55 UTC (rev 17807)
@@ -213,7 +213,7 @@
 				GError **error)
 {
 	GdkPixbuf *pixbuf;
-	gchar *large, *normal, *cropped, *filen;
+	gchar *large, *normal, *cropped, *filen, *temp;
 	struct utimbuf buf;
 	GError *nerror = NULL;
 
@@ -237,11 +237,18 @@
 					   bits_per_sample, width, height, rowstride,
 					   NULL, NULL);
 
-	gdk_pixbuf_save (pixbuf, filen, "jpeg", 
+	temp = g_strdup_printf ("%s.tmp", filen);
+
+	gdk_pixbuf_save (pixbuf, temp, "jpeg", 
 			 &nerror, NULL);
 
 	g_object_unref (pixbuf);
 
+	if (!nerror)
+		g_rename (temp, filen);
+
+	g_free (temp);
+
 	if (!nerror) {
 #ifdef HAVE_SQLITE3
 		gboolean create = FALSE;

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c	2009-03-26 10:06:17 UTC (rev 17806)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c	2009-03-26 10:58:55 UTC (rev 17807)
@@ -235,9 +235,10 @@
 				GError **error)
 {
 	GdkPixbuf *pixbuf;
-	gchar *large, *normal, *cropped, *filen;
+	gchar *large, *normal, *cropped, *filen, *temp;
 	char mtime_str[64];
 	struct utimbuf buf;
+	GError *nerror = NULL;
 
 	const char *default_keys[] = {
 		URI_OPTION,
@@ -276,17 +277,25 @@
 
 	g_sprintf (mtime_str, "%Lu", mtime);
 
-	gdk_pixbuf_savev (pixbuf, filen, "png", 
+	temp = g_strdup_printf ("%s.tmp", filen);
+
+	gdk_pixbuf_savev (pixbuf, temp, "png", 
 			  (char **) default_keys, 
 			  (char **) default_values, 
-			  error);
+			  &nerror);
 
 	g_object_unref (pixbuf);
 
-	buf.actime = buf.modtime = mtime;
+	if (!nerror) {
+		g_rename (temp, filen);
+		buf.actime = buf.modtime = mtime;
+		utime (filen, &buf);
+	} else
+		g_propagate_error (error, nerror);
 
-	utime (filen, &buf);
+	g_free (temp);
 
+
 	g_free (normal);
 	g_free (large);
 	g_free (cropped);


More information about the maemo-commits mailing list