[f-spot] Only load photo dates when needed.



commit 4066ef58c394926b581d50b29a0fb70a806b099c
Author: Ruben Vermeersch <ruben savanne be>
Date:   Thu Jun 10 00:14:02 2010 +0200

    Only load photo dates when needed.
    
    Makes import preparation massively faster. Scrolling in iconview a bit
    slower though.

 src/Import/FileImportSource.cs |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/Import/FileImportSource.cs b/src/Import/FileImportSource.cs
index 6551b72..23aa7c4 100644
--- a/src/Import/FileImportSource.cs
+++ b/src/Import/FileImportSource.cs
@@ -139,22 +139,28 @@ namespace FSpot.Import
         {
             DefaultVersion = new ImportInfoVersion () {
                 BaseUri = original.GetBaseUri (),
-                        Filename = original.GetFilename ()
+                Filename = original.GetFilename ()
             };
-
-            try {
-                using (FSpot.ImageFile img = FSpot.ImageFile.Create (original)) {
-                    Time = img.Date;
-                }
-            } catch (Exception) {
-                Time = DateTime.Now;
-            }
         }
 
         public IBrowsableItemVersion DefaultVersion { get; private set; }
         public SafeUri DestinationUri { get; set; }
 
-        public System.DateTime Time { get; private set; }
+        private DateTime? time = null;
+        public System.DateTime Time {
+            get {
+                if (!time.HasValue) {
+                    try {
+                        using (FSpot.ImageFile img = FSpot.ImageFile.Create (DefaultVersion.Uri)) {
+                            time = img.Date;
+                        }
+                    } catch (Exception) {
+                        time = DateTime.Now;
+                    }
+                }
+                return time.Value;
+            }
+        }
 
         public Tag [] Tags { get { throw new NotImplementedException (); } }
         public string Description { get { throw new NotImplementedException (); } }



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