[gnome-shell] network: remove the vpn request when it's serviced



commit baacd216ddc72054adf226bfc1eabe59e0dce7c8
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Dec 6 16:55:15 2017 +0100

    network: remove the vpn request when it's serviced
    
    The native agent already forgets about the request at the point it's
    serviced and the further attempt to use it (e.g. cancel it when the screen
    is locked) will trigger an assertion failure:
    
      ** (gnome-shell:30862): CRITICAL **: shell_network_agent_respond: assertion 'request != NULL' failed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789811

 js/ui/components/networkAgent.js |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js
index 5faabb6..a591d05 100644
--- a/js/ui/components/networkAgent.js
+++ b/js/ui/components/networkAgent.js
@@ -8,6 +8,7 @@ const Lang = imports.lang;
 const NM = imports.gi.NM;
 const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
+const Signals = imports.signals;
 const St = imports.gi.St;
 
 const Config = imports.misc.config;
@@ -413,7 +414,9 @@ var VPNRequestHandler = new Lang.Class({
         if (this._destroyed)
             return;
 
-        GLib.source_remove(this._childWatch);
+        this.emit('destroy');
+        if (this._childWatch)
+            GLib.source_remove(this._childWatch);
 
         this._stdin.close(null);
         // Stdout is closed when we finish reading from it
@@ -540,6 +543,7 @@ var VPNRequestHandler = new Lang.Class({
                 logError(e, 'error while reading VPN plugin output keyfile');
 
                 this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
+                this.destroy();
                 return;
             }
         }
@@ -550,6 +554,7 @@ var VPNRequestHandler = new Lang.Class({
             this._shellDialog.open(global.get_current_time());
         } else {
             this._agent.respond(this._requestId, Shell.NetworkAgentResponse.CONFIRMED);
+            this.destroy();
         }
     },
 
@@ -570,9 +575,11 @@ var VPNRequestHandler = new Lang.Class({
             logError(e, 'internal error while writing connection to helper');
 
             this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
+            this.destroy();
         }
     },
 });
+Signals.addSignalMethods(VPNRequestHandler.prototype);
 
 var NetworkAgent = new Lang.Class({
     Name: 'NetworkAgent',
@@ -740,7 +747,11 @@ var NetworkAgent = new Lang.Class({
             return;
         }
 
-        this._vpnRequests[requestId] = new VPNRequestHandler(this._native, requestId, binary, serviceType, 
connection, hints, flags);
+        let vpnRequest = new VPNRequestHandler(this._native, requestId, binary, serviceType, connection, 
hints, flags);
+        vpnRequest.connect('destroy', Lang.bind(this, function() {
+            delete this._vpnRequests[requestId];
+        }));
+        this._vpnRequests[requestId] = vpnRequest;
     },
 
     _buildVPNServiceCache: function() {


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