[geary/wip/fast-folder-switching-crashes] Both check for and throw Cancelled errors some more



commit 76222c781006cb26965a4815c2e8f113a74ba56a
Author: Michael Gratton <mike vee net>
Date:   Sun Apr 21 16:23:30 2019 +1000

    Both check for and throw Cancelled errors some more
    
    Fixes some crashes when switching folders by keeping the down arrow
    held down.

 src/client/application/application-contact-store.vala  | 9 +++++----
 src/client/conversation-viewer/conversation-email.vala | 8 ++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/client/application/application-contact-store.vala 
b/src/client/application/application-contact-store.vala
index 8aa2b96e..8603d8f8 100644
--- a/src/client/application/application-contact-store.vala
+++ b/src/client/application/application-contact-store.vala
@@ -98,10 +98,6 @@ public class Application.ContactStore : Geary.BaseObject {
     private async Folks.Individual? search_match(string address,
                                                  GLib.Cancellable cancellable)
         throws GLib.Error {
-        if (cancellable.is_cancelled()) {
-            throw new GLib.IOError.CANCELLED("Contact load was cancelled");
-        }
-
         Folks.SearchView view = new Folks.SearchView(
             this.individuals,
             new Folks.SimpleQuery(
@@ -126,6 +122,11 @@ public class Application.ContactStore : Geary.BaseObject {
         } catch (GLib.Error err) {
             warning("Error unpreparing Folks search: %s", err.message);
         }
+
+        if (cancellable.is_cancelled()) {
+            throw new GLib.IOError.CANCELLED("Contact load was cancelled");
+        }
+
         return match;
     }
 
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index b8ce0e49..87a84b28 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -574,6 +574,9 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
             debug("Contact load failed for \"%s\": %s",
                   from != null ? from.to_string() : "<unknown>", err.message);
         }
+        if (this.load_cancellable.is_cancelled()) {
+            throw new GLib.IOError.CANCELLED("Contact load was cancelled");
+        }
     }
 
     /**
@@ -622,6 +625,9 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
         if (loaded) {
             try {
                 yield update_body();
+            } catch (GLib.IOError.CANCELLED err) {
+                this.body_loading_timeout.reset();
+                throw err;
             } catch (GLib.Error err) {
                 this.body_loading_timeout.reset();
                 handle_load_failure(err);
@@ -792,6 +798,8 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
                 try {
                     this.email = loaded;
                     yield update_body();
+                } catch (GLib.IOError.CANCELLED err) {
+                    // All good
                 } catch (GLib.Error err) {
                     debug("Remote message update failed: %s", err.message);
                     handle_load_failure(err);


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