[gnome-shell-extensions/wip/fmuellner/fix-proxy-dispose: 2/2] places-menu: Don't force dispose() of uninitialized proxies



commit 3284fe81d7cdb362fc7d8013bf7d958b253c4b44
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Jan 17 21:57:49 2018 +0100

    places-menu: Don't force dispose() of uninitialized proxies
    
    Trying to dispose a proxy object before it has been properly
    initialized triggers an "uncatchable exception", which gjs
    treats as a fatal error since commit c7bdcaab4. We only have
    anything to clean up once the proxy is initialized anyway, so
    don't force dispose() before that.
    
    https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/44

 extensions/places-menu/placeDisplay.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js
index 568184d..4fe6808 100644
--- a/extensions/places-menu/placeDisplay.js
+++ b/extensions/places-menu/placeDisplay.js
@@ -136,10 +136,11 @@ class RootInfo extends PlaceInfo {
 
         let busName = 'org.freedesktop.hostname1';
         let objPath = '/org/freedesktop/hostname1';
-        this._proxy = new Hostname1(Gio.DBus.system, busName, objPath, (obj, error) => {
+        new Hostname1(Gio.DBus.system, busName, objPath, (obj, error) => {
             if (error)
                 return;
 
+            this._proxy = obj;
             this._proxy.connect('g-properties-changed',
                                 this._propertiesChanged.bind(this));
             this._propertiesChanged(obj);
@@ -160,7 +161,10 @@ class RootInfo extends PlaceInfo {
     }
 
     destroy() {
-        this._proxy.run_dispose();
+        if (this._proxy) {
+            this._proxy.run_dispose();
+            this._proxy = null;
+        }
         super.destroy();
     }
 };


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