[f-spot/FSPOT_0_6_0_STABLE] Prevent crash on broken EXIF exposure data.



commit ff42393bcb3053c689c0793c2ed16403802d40f0
Author: Karl Mikaelsson <derfian lysator liu se>
Date:   Sun Aug 30 13:25:45 2009 +0200

    Prevent crash on broken EXIF exposure data.
    
    Fixes bgo #595503

 src/Widgets/InfoBox.cs |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/Widgets/InfoBox.cs b/src/Widgets/InfoBox.cs
index da45e8b..8b7b11b 100644
--- a/src/Widgets/InfoBox.cs
+++ b/src/Widgets/InfoBox.cs
@@ -382,12 +382,20 @@ namespace FSpot.Widgets
 					string info = String.Empty;
 	
 					if  (fnumber != null && fnumber != String.Empty) {
-						FSpot.Tiff.Rational rat = new FSpot.Tiff.Rational (fnumber);
-						info += String.Format ("f/{0:.0} ", rat.Value);
+						try {
+							FSpot.Tiff.Rational rat = new FSpot.Tiff.Rational (fnumber);
+							info += String.Format ("f/{0:.0} ", rat.Value);
+						} catch (FormatException) {
+							return Catalog.GetString("(wrong format)");
+						}
 					} else if (aperture != null && aperture != String.Empty) {
-						// Convert from APEX to fnumber
-						FSpot.Tiff.Rational rat = new FSpot.Tiff.Rational (aperture);
-						info += String.Format ("f/{0:.0} ", Math.Pow (2, rat.Value / 2));
+						try {
+							// Convert from APEX to fnumber
+							FSpot.Tiff.Rational rat = new FSpot.Tiff.Rational (aperture);
+							info += String.Format ("f/{0:.0} ", Math.Pow (2, rat.Value / 2));
+						} catch (FormatException) {
+							return Catalog.GetString ("(wrong format)");
+						}
 					}
 	
 					if (exposure != null && exposure != String.Empty)



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