[geary/wip/fix-first-run-deadlock] Fix a deadlock resulting in no UI being shown on first run



commit 976e989b8c779f20359341541e531758d1873404
Author: Michael Gratton <mike vee net>
Date:   Sun Aug 25 10:23:16 2019 +1000

    Fix a deadlock resulting in no UI being shown on first run
    
    After switching to DBus activation, we need to ensure that a controller
    is present when arbitrary GApplication actions are executed so a
    main window also exists. This lead to a deadlock on first run since
    when the application was activated, it would be in the middle of
    constructing the controller when it showed the Accounts Editor, which
    would block since it would also try to construct a controller.
    
    This fixes the deadlock by moving the first-run check to the
    application, outside of the lock.

 src/client/application/application-controller.vala |  8 --------
 src/client/application/geary-application.vala      | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/client/application/application-controller.vala 
b/src/client/application/application-controller.vala
index 9cae7a97..ea70af67 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -378,14 +378,6 @@ public class Application.Controller : Geary.BaseObject {
                 this.application.get_resource_directory(), cancellable
             );
             yield this.account_manager.load_accounts(cancellable);
-            if (engine.get_accounts().size == 0) {
-                yield this.application.show_accounts();
-                if (engine.get_accounts().size == 0) {
-                    // User cancelled without creating an account, so
-                    // nothing else to do but exit.
-                    this.application.quit();
-                }
-            }
         } catch (Error e) {
             warning("Error opening Geary.Engine instance: %s", e.message);
         }
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index e6e078f4..d9dab358 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -704,6 +704,7 @@ public class GearyApplication : Gtk.Application {
         // hit the yield below, before we create the main window.
         hold();
 
+        bool first_run = false;
         try {
             int mutex_token = yield this.controler_mutex.claim_async();
             if (this.controller == null) {
@@ -720,12 +721,26 @@ public class GearyApplication : Gtk.Application {
                 this.controller = yield new Application.Controller(
                     this, this.controller_cancellable
                 );
+
+                if (this.engine.get_accounts().size == 0) {
+                    first_run = true;
+                }
             }
             this.controler_mutex.release(ref mutex_token);
         } catch (Error err) {
             error("Error creating controller: %s", err.message);
         }
 
+        if (first_run) {
+            yield show_accounts();
+            if (this.engine.get_accounts().size == 0) {
+                // No accounts were added after showing the accounts
+                // editor, accounts editor, so nothing else to do but
+                // exit.
+                quit();
+            }
+        }
+
         release();
     }
 


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