[gnome-shell] polkitAgent: Cancel session after disconnecting signal handlers



commit 45ebb94b33e03857268f7665762a92d37c632acd
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sun Jun 23 13:11:58 2019 +0200

    polkitAgent: Cancel session after disconnecting signal handlers
    
    When cancelling the PolkitAgent session before disconnecting the signal
    handlers, we receive a "completed" signal where `gained_authorization`
    is set to FALSE, which means we show an error message inside
    `_onSessionCompleted()`.
    
    This in turn means we show an error message every time we cancel a
    session. In practice this wasn't really relevant so far since we only
    destroyed the session when an actual error occurred before. Now that the
    dialog supports empty passwords, we also call `_destroySession()` when
    the user changes and no longer has a password set, and in this case we
    want to cancel the current session without showing an error message.
    
    So to fix this, disconnect the signal handlers before cancelling the
    session, which makes sure we don't receive the last "completed" signal
    in case we cancelled the session ourselves. This change also allows
    removing `this._wasDismissed`.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/829

 js/ui/components/polkitAgent.js | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js
index 05d4682cd3..a25d651003 100644
--- a/js/ui/components/polkitAgent.js
+++ b/js/ui/components/polkitAgent.js
@@ -31,7 +31,6 @@ var AuthenticationDialog = GObject.registerClass({
         this.actionId = actionId;
         this.message = body;
         this.userNames = userNames;
-        this._wasDismissed = false;
 
         this._sessionUpdatedId = Main.sessionMode.connect('updated', () => {
             this.visible = !Main.sessionMode.isLocked;
@@ -249,7 +248,7 @@ var AuthenticationDialog = GObject.registerClass({
              * error providing authentication-method specific information),
              * show "Sorry, that didn't work. Please try again."
              */
-            if (!this._errorMessageLabel.visible && !this._wasDismissed) {
+            if (!this._errorMessageLabel.visible) {
                 /* Translators: "that didn't work" refers to the fact that the
                  * requested authentication was not gained; this can happen
                  * because of an authentication error (like invalid password),
@@ -312,14 +311,15 @@ var AuthenticationDialog = GObject.registerClass({
 
     _destroySession(delay = 0) {
         if (this._session) {
-            if (!this._completed)
-                this._session.cancel();
-            this._completed = false;
-
             this._session.disconnect(this._sessionCompletedId);
             this._session.disconnect(this._sessionRequestId);
             this._session.disconnect(this._sessionShowErrorId);
             this._session.disconnect(this._sessionShowInfoId);
+
+            if (!this._completed)
+                this._session.cancel();
+
+            this._completed = false;
             this._session = null;
         }
 
@@ -381,7 +381,6 @@ var AuthenticationDialog = GObject.registerClass({
     }
 
     cancel() {
-        this._wasDismissed = true;
         this.close(global.get_current_time());
         this._emitDone(true);
     }


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