[f-spot/rubenv-gsoc-2009: 52/86] Add some more error checking and correctly install DLL maps.



commit bb91bffd7332f4d05a52e702155cc6b02716b5c7
Author: Ruben Vermeersch <ruben savanne be>
Date:   Tue Aug 4 16:10:36 2009 +0200

    Add some more error checking and correctly install DLL maps.

 lib/libfspotraw/fspot-librawloader.cpp |   14 +++++++++-----
 src/Loaders/LibrawImageLoader.cs       |   18 +++++++++++++-----
 src/Makefile.am                        |    2 ++
 3 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/lib/libfspotraw/fspot-librawloader.cpp b/lib/libfspotraw/fspot-librawloader.cpp
index e6e5907..4642dbd 100644
--- a/lib/libfspotraw/fspot-librawloader.cpp
+++ b/lib/libfspotraw/fspot-librawloader.cpp
@@ -40,7 +40,7 @@ fspot_librawloader_get_property (GObject	  *object,
 static void fspot_librawloader_dispose (GObject *object);
 static void fspot_librawloader_finalize (GObject *object);
 
-static void open_if_needed (FSpotLibrawLoader *self);
+static gboolean open_if_needed (FSpotLibrawLoader *self);
 static void pixbuf_freed (guchar *pixels, gpointer data);
 
 static int libraw_progress_callback (void *user_data, enum LibRaw_progress p, int iteration, int expected);
@@ -191,7 +191,8 @@ fspot_librawloader_load_embedded (FSpotLibrawLoader *self, int *orientation)
 	GdkPixbuf *pixbuf = NULL;
 	GError *error = NULL;
 
-	open_if_needed (self);
+	if (!open_if_needed (self))
+		return NULL;
 
 	self->priv->raw_proc->unpack_thumb ();
 	image = self->priv->raw_proc->dcraw_make_mem_thumb (&result);
@@ -221,7 +222,8 @@ fspot_librawloader_load_full (FSpotLibrawLoader *self)
 	libraw_processed_image_t *image = NULL;
 	GdkPixbuf *pixbuf = NULL;
 
-	open_if_needed (self);
+	if (!open_if_needed (self))
+		return NULL;
 
 	self->priv->raw_proc->unpack ();
 	self->priv->raw_proc->dcraw_process ();
@@ -263,16 +265,18 @@ fspot_librawloader_new (const gchar *filename)
 	return loader;
 }
 
-static void
+static gboolean
 open_if_needed (FSpotLibrawLoader *self)
 {
 	if (!self->priv->opened) {
 		self->priv->raw_proc->imgdata.params.use_camera_wb = 1;
 		int result = self->priv->raw_proc->open_file (self->priv->filename);
-		g_assert (result == 0);
+		if (result != 0)
+			return FALSE;
 
 		self->priv->opened = true;
 	}
+	return TRUE;
 }
 
 static int
diff --git a/src/Loaders/LibrawImageLoader.cs b/src/Loaders/LibrawImageLoader.cs
index 7d23064..f72976b 100644
--- a/src/Loaders/LibrawImageLoader.cs
+++ b/src/Loaders/LibrawImageLoader.cs
@@ -30,20 +30,20 @@ namespace FSpot.Loaders {
 
 		Pixbuf thumbnail;
 		public Pixbuf Thumbnail {
-			get { return thumbnail.ShallowCopy (); }
+			get { return thumbnail == null ? null : thumbnail.ShallowCopy (); }
 			private set { thumbnail = value; }
 		}
 		public PixbufOrientation ThumbnailOrientation { get; private set; }
 
 		Pixbuf large;
 		public Pixbuf Large {
-			get { return large.ShallowCopy (); }
+			get { return large == null ? null : large.ShallowCopy (); }
 		}
 		public PixbufOrientation LargeOrientation { get; private set; }
 
 		Pixbuf full;
 		public Pixbuf Full {
-			get { return full.ShallowCopy (); }
+			get { return full == null ? null : full.ShallowCopy (); }
 		}
 		public PixbufOrientation FullOrientation { get; private set; }
 
@@ -163,13 +163,17 @@ namespace FSpot.Loaders {
 			// for the next call to generate it (see the loop in DoLoad).
 			if (!ThumbnailFactory.ThumbnailExists (uri)) {
 				if (ItemsCompleted.Contains (ImageLoaderItem.Large)) {
-					if (large != null)
+					if (large != null) {
 						using (Pixbuf scaled = PixbufUtils.ScaleToMaxSize (large, 256, 256, false)) {
 							Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (scaled, LargeOrientation);
 							ThumbnailFactory.SaveThumbnail (rotated, uri);
 							if (rotated != scaled)
 								rotated.Dispose ();
 						}
+					} else {
+						SignalItemCompleted (ImageLoaderItem.Thumbnail);
+						return;
+					}
 				} else {
 					ItemsRequested |= ImageLoaderItem.Large;
 					return;
@@ -197,8 +201,12 @@ namespace FSpot.Loaders {
 			if (large == null) {
 				// Fallback for files without an embedded preview (yuck!)
 				LoadFull ();
-				if (full != null)
+				if (full != null) {
 					large = full.ShallowCopy ();
+				} else {
+					SignalItemCompleted (ImageLoaderItem.Large);
+					return;
+				}
 			}
 
 			switch (orientation) {
diff --git a/src/Makefile.am b/src/Makefile.am
index 1d23f07..f02c0fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -495,8 +495,10 @@ fspotlib_DATA = f-spot.exe.config	\
 		FSpot.Utils.dll.config	\
 		FSpot.Imaging.dll		\
 		FSpot.Imaging.dll.mdb	\
+		FSpot.Imaging.dll.config	\
 		FSpot.Loaders.dll		\
 		FSpot.Loaders.dll.mdb	\
+		FSpot.Loaders.dll.config	\
 		FSpot.Query.dll		\
 		FSpot.Query.dll.mdb	\
 		FSpot.Core.dll		\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]