diff src/image-load.c @ 60:9c0c402b0ef3

Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net> * editors.[ch]: Add "%w" macro to disable full screen deactivation when running an editor command. * img-view.c, layout_image.c, pan-view.c: Honor %w editor flag to prevent exit of full screen. * image-load.c (image_load_begin): Fix to not treat short reads as end of file condition. * README, doc/10_5_editor_commands.html: Document %w macro for editor commands. * po/it.po: Update Italian translation, submitted by Kostantino <inverness1ATvirgilio.it>.
author gqview
date Mon, 13 Jun 2005 21:39:13 +0000
parents b58cac75ad12
children 71e1ebee420e
line wrap: on
line diff
--- a/src/image-load.c	Sun Jun 12 23:45:45 2005 +0000
+++ b/src/image-load.c	Mon Jun 13 21:39:13 2005 +0000
@@ -217,7 +217,7 @@
 
 	b = read(il->load_fd, &buf, sizeof(buf));
 
-	if (b > 1 &&
+	if (b > 0 &&
 	    format_raw_img_exif_offsets_fd(il->load_fd, il->path, buf, b, &offset, NULL))
 		{
 		if (debug) printf("Raw file %s contains embedded image\n", il->path);
@@ -231,66 +231,47 @@
 		return FALSE;
 		}
 
-	if (gdk_pixbuf_loader_write(il->loader, buf, b, NULL))
-		{
-		il->bytes_read += b + offset;
-
-		if (b < sizeof(buf))
-			{
-			/* end of file already */
-
-			image_loader_stop(il);
-
-			if (!il->pixbuf) return FALSE;
-
-			image_loader_done_delay(il);
-			return TRUE;
-			}
-		else
-			{
-			/* larger file */
-
-			/* read until size is known */
-			while(il->loader && !gdk_pixbuf_loader_get_pixbuf(il->loader) && b > 0)
-				{
-				b = read(il->load_fd, &buf, sizeof(buf));
-				if (b < 0 || (b > 0 && !gdk_pixbuf_loader_write(il->loader, buf, b, NULL)))
-					{
-					image_loader_stop(il);
-					return FALSE;
-					}
-				il->bytes_read += b;
-				}
-			if (!il->pixbuf) image_loader_sync_pixbuf(il);
-
-			if (il->bytes_read == il->bytes_total || b < sizeof(buf))
-				{
-				/* done, handle (broken) loaders that do not have pixbuf till close */
-				image_loader_stop(il);
-
-				if (!il->pixbuf) return FALSE;
-
-				image_loader_done_delay(il);
-				return TRUE;
-				}
-
-			if (!il->pixbuf)
-				{
-				image_loader_stop(il);
-				return FALSE;
-				}
-
-			/* finally, progressive loading :) */
-			il->idle_id = g_idle_add_full(il->idle_priority, image_loader_idle_cb, il, NULL);
-			return TRUE;
-			}
-		}
-	else
+	if (!gdk_pixbuf_loader_write(il->loader, buf, b, NULL))
 		{
 		image_loader_stop(il);
 		return FALSE;
 		}
 
+	il->bytes_read += b + offset;
+
+	/* read until size is known */
+	while (il->loader && !gdk_pixbuf_loader_get_pixbuf(il->loader) && b > 0)
+		{
+		b = read(il->load_fd, &buf, sizeof(buf));
+		if (b < 0 || (b > 0 && !gdk_pixbuf_loader_write(il->loader, buf, b, NULL)))
+			{
+			image_loader_stop(il);
+			return FALSE;
+			}
+		il->bytes_read += b;
+		}
+	if (!il->pixbuf) image_loader_sync_pixbuf(il);
+
+	if (il->bytes_read == il->bytes_total || b < 1)
+		{
+		/* done, handle (broken) loaders that do not have pixbuf till close */
+		image_loader_stop(il);
+
+		if (!il->pixbuf) return FALSE;
+
+		image_loader_done_delay(il);
+		return TRUE;
+		}
+
+	if (!il->pixbuf)
+		{
+		image_loader_stop(il);
+		return FALSE;
+		}
+
+	/* finally, progressive loading :) */
+	il->idle_id = g_idle_add_full(il->idle_priority, image_loader_idle_cb, il, NULL);
+
 	return TRUE;
 }