[gnome-shell/wip/sass] Calendar: ignore timeouts starting the calendar-server



commit 63235e01c4de7202bd735d1492fd8452f767e138
Author: Giovanni Campagna <scampa giovanni gmail com>
Date:   Wed Dec 10 16:41:48 2014 -0800

    Calendar: ignore timeouts starting the calendar-server
    
    In certain cases the timeout for starting the calendar helper can
    be reached but the calendar helper still loads fine. If so, just
    ignore the timeout and wait until we get a notification from
    dbus of the successful start.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735308

 js/ui/calendar.js |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 4132c00..5d6d230 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -233,11 +233,24 @@ const DBusEventSource = new Lang.Class({
         this._initialized = false;
         this._dbusProxy = new CalendarServer();
         this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(object, result) {
+            let loaded = false;
+
             try {
                 this._dbusProxy.init_finish(result);
+                loaded = true;
             } catch(e) {
-                log('Error loading calendars: ' + e.message);
-                return;
+                if (e.matches(Gio.DBusError, Gio.DBusError.TIMED_OUT)) {
+                    // Ignore timeouts and install signals as normal, because with high
+                    // probability the service will appear later on, and we will get a
+                    // NameOwnerChanged which will finish loading
+                    //
+                    // (But still _initialized to false, because the proxy does not know
+                    // about the HasCalendars property and would cause an exception trying
+                    // to read it)
+                } else {
+                    log('Error loading calendars: ' + e.message);
+                    return;
+                }
             }
 
             this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
@@ -253,9 +266,11 @@ const DBusEventSource = new Lang.Class({
                 this.emit('notify::has-calendars');
             }));
 
-            this._initialized = true;
-            this.emit('notify::has-calendars');
-            this._onNameAppeared();
+            this._initialized = loaded;
+            if (loaded) {
+                this.emit('notify::has-calendars');
+                this._onNameAppeared();
+            }
         }));
     },
 
@@ -277,6 +292,7 @@ const DBusEventSource = new Lang.Class({
     },
 
     _onNameAppeared: function(owner) {
+        this._initialized = true;
         this._resetCache();
         this._loadEvents(true);
     },


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