[geary] Fix error validing account details on second try. Bug 775511



commit dbf0251646394e2d67cfcb233df4d9afe3e2fd93
Author: Michael James Gratton <mike vee net>
Date:   Fri Feb 17 17:35:23 2017 +1100

    Fix error validing account details on second try. Bug 775511
    
    * src/client/accounts/add-edit-page.vala
      (AddEditPage::get_account_information): Handle when the id is not null,
      but the account has not yet been added to the engine, as is the case
      when a new account has vailed validation and hence is an orphan.

 src/client/accounts/add-edit-page.vala |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/client/accounts/add-edit-page.vala b/src/client/accounts/add-edit-page.vala
index 83d5992..a4b53b3 100644
--- a/src/client/accounts/add-edit-page.vala
+++ b/src/client/accounts/add-edit-page.vala
@@ -654,7 +654,21 @@ public class AddEditPage : Gtk.Box {
             (smtp_use_imap_credentials ? imap_password.strip() : smtp_password.strip()));
 
         Geary.AccountInformation? info = null;
-        if (this.id == null) {
+        if (this.id != null) {
+            // The id will be null in the case of adding a new
+            // account, but it won't be null and yet the account won't
+            // be accessible via Engine.get_account() in the case of
+            // an orphan account - i.e. when adding an account
+            // encountered validation errors. So we need to deal with
+            // both cases.
+            try {
+                info = Geary.Engine.instance.get_account(this.id);
+            } catch (Error err) {
+                // id was for an orphan account
+            }
+        }
+
+        if (info == null) {
             // New account
             try {
                 info = Geary.Engine.instance.create_orphan_account();
@@ -663,14 +677,9 @@ public class AddEditPage : Gtk.Box {
                       this.id, this.email_address, err.message);
             }
         } else {
-            // Existing account: create a copy so we don't mess up the original.
-            try {
-                info = new Geary.AccountInformation.temp_copy(
-                    Geary.Engine.instance.get_account(this.id)
-                );
-            } catch (Error err) {
-                debug("Unable get existing account %s: %s", this.id, err.message);
-            }
+            // Existing account: create a copy so we don't mess up the
+            // original.
+            info = new Geary.AccountInformation.temp_copy(info);
         }
 
         if (info != null) {


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