[shotwell] Do not endlessly create thumbs



commit 8cf7a7a4743cbe2a7acfc71423acb81f7efd0f2e
Author: Jens Georg <mail jensge org>
Date:   Sun Jul 9 22:19:36 2017 +0200

    Do not endlessly create thumbs
    
    notify_altered("image", ... will trigger thumnail re-genration and in
    consequence other events, and it does all of this twice. Otoh, the
    thumbnail is already generated on inport.

 src/BatchImport.vala |    2 +-
 src/Photo.vala       |   23 +++++++++++++----------
 2 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/BatchImport.vala b/src/BatchImport.vala
index 675fef0..116e001 100644
--- a/src/BatchImport.vala
+++ b/src/BatchImport.vala
@@ -1067,7 +1067,7 @@ public class BatchImport : Object {
                         d = RawDeveloper.EMBEDDED;
                     
                     photo.set_default_raw_developer(d);
-                    photo.set_raw_developer(d);
+                    photo.set_raw_developer(d, false);
                 }
             }
             
diff --git a/src/Photo.vala b/src/Photo.vala
index cf051ec..c290943 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -628,12 +628,14 @@ public abstract class Photo : PhotoSource, Dateable {
     // Reads info on a backing photo and adds it.
     // Note: this function was created for importing new photos.  It will not
     // notify of changes to the developments.
-    public void add_backing_photo_for_development(RawDeveloper d, BackingPhotoRow bpr) throws Error {
+    public void add_backing_photo_for_development(RawDeveloper d, BackingPhotoRow bpr, bool notify = true) 
throws Error {
         import_developed_backing_photo(row, d, bpr);
         lock (developments) {
             developments.set(d, bpr);
         }
-        notify_altered(new Alteration("image", "developer"));
+
+        if (notify)
+            notify_altered(new Alteration("image", "developer"));
     }
     
     public static void import_developed_backing_photo(PhotoRow row, RawDeveloper d, 
@@ -667,7 +669,7 @@ public abstract class Photo : PhotoSource, Dateable {
     
     // "Develops" a raw photo
     // Not thread-safe.
-    private void develop_photo(RawDeveloper d) {
+    private void develop_photo(RawDeveloper d, bool notify) {
         bool wrote_img_to_disk = false;
         BackingPhotoRow bps = null;
         
@@ -714,7 +716,7 @@ public abstract class Photo : PhotoSource, Dateable {
                     if (wrote_img_to_disk) {
                         try {
                             // Read in backing photo info, add to DB.
-                            add_backing_photo_for_development(d, bps);
+                            add_backing_photo_for_development(d, bps, notify);
                             
                             notify_raw_development_modified();
                         } catch (Error e) {
@@ -784,7 +786,7 @@ public abstract class Photo : PhotoSource, Dateable {
                     if (wrote_img_to_disk) {
                         try {
                             // Read in backing photo info, add to DB.
-                            add_backing_photo_for_development(d, bps);
+                            add_backing_photo_for_development(d, bps, notify);
                             
                             notify_raw_development_modified();
                         } catch (Error e) {
@@ -808,7 +810,7 @@ public abstract class Photo : PhotoSource, Dateable {
     }
     
     // Sets the developer and develops the photo.
-    public void set_raw_developer(RawDeveloper d) {
+    public void set_raw_developer(RawDeveloper d, bool notify = true) {
         if (get_master_file_format() != PhotoFileFormat.RAW)
             return;
         
@@ -828,7 +830,7 @@ public abstract class Photo : PhotoSource, Dateable {
             
             // Perform development, bail out if it doesn't work.
             if (!is_raw_developer_complete(d)) {
-                develop_photo(d);
+                develop_photo(d, notify);
             }
             if (!developments.has_key(d))
                 return; // we tried!
@@ -871,14 +873,15 @@ public abstract class Photo : PhotoSource, Dateable {
             // and is to be preserved.
         }
         
-        notify_altered(new Alteration("image", "developer"));
+        if (notify)
+            notify_altered(new Alteration("image", "developer"));
         discard_prefetched();
     }
-    
+
     public RawDeveloper get_raw_developer() {
         return row.developer;
     }
-    
+
     // Removes a development from the database, filesystem, etc.
     // Returns true if a development was removed, otherwise false.
     private bool delete_raw_development(RawDeveloper d) {


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