[gnome-shell/gnome-3-36] gdm: Don't try answering query if the user verifier has been deleted



commit cf38c2558272a4188a71e5de72cd7a299d0a467e
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Mon Feb 1 16:42:21 2021 +0100

    gdm: Don't try answering query if the user verifier has been deleted
    
    Answering a query may be delayed to the moment in which we've not any
    more messages in the queue, however this case can also happen just after
    we've cleared the UserVerifier and in such case we'd have nothing to
    answer, but we currently throw an error:
    
        JS ERROR: Exception in callback for signal: no-more-messages:
          TypeError: this._userVerifier is null
        answerQuery/signalId<@resource:///org/gnome/shell/gdm/util.js:249:17
        _emit@resource:///org/gnome/gjs/modules/core/_signals.js:133:47
        finishMessageQueue@resource:///org/gnome/shell/gdm/util.js:266:14
        _clearMessageQueue@resource:///org/gnome/shell/gdm/util.js:301:14
        clear@resource:///org/gnome/shell/gdm/util.js:223:14
        cancel@resource:///org/gnome/shell/gdm/util.js:205:18
        reset@resource:///org/gnome/shell/gdm/authPrompt.js:482:32
        cancel@resource:///org/gnome/shell/gdm/authPrompt.js:569:14
        vfunc_key_press_event@resource:///org/gnome/shell/gdm/authPrompt.js:128
    
    So handle this case more gracefully keeping track of the current
    cancellable and checking whether it is still valid before trying to answer
    a query or do a delayed action.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1784>

 js/gdm/util.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/js/gdm/util.js b/js/gdm/util.js
index 3de5d2a611..ce2e7abfd4 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -223,9 +223,11 @@ var ShellUserVerifier = class {
         if (!this.hasPendingMessages) {
             this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
         } else {
+            const cancellable = this._cancellable;
             let signalId = this.connect('no-more-messages', () => {
                 this.disconnect(signalId);
-                this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
+                if (!cancellable.is_cancelled())
+                    this._userVerifier.call_answer_query(serviceName, answer, cancellable, null);
             });
         }
     }
@@ -537,9 +539,10 @@ var ShellUserVerifier = class {
             if (!this.hasPendingMessages) {
                 this._retry();
             } else {
+                const cancellable = this._cancellable;
                 let signalId = this.connect('no-more-messages', () => {
                     this.disconnect(signalId);
-                    if (this._cancellable && !this._cancellable.is_cancelled())
+                    if (!cancellable.is_cancelled())
                         this._retry();
                 });
             }
@@ -548,9 +551,11 @@ var ShellUserVerifier = class {
             if (!this.hasPendingMessages) {
                 this._cancelAndReset();
             } else {
+                const cancellable = this._cancellable;
                 let signalId = this.connect('no-more-messages', () => {
                     this.disconnect(signalId);
-                    this._cancelAndReset();
+                    if (!cancellable.is_cancelled())
+                        this._cancelAndReset();
                 });
             }
         }


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