Skip to content

Commit

Permalink
polkitAuthenticationAgent.js: Improve initialization, cleanup of
Browse files Browse the repository at this point in the history
signal and timer handles.
  • Loading branch information
mtwebster committed Dec 31, 2024
1 parent 6d990e7 commit 4c4bd53
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions js/ui/polkitAuthenticationAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ var AuthenticationDialog = GObject.registerClass({
this._visibleAvatar = null;
this._adminUsers = [];

this._sessionCompletedId = 0;
this._sessionRequestId = 0;
this._sessionShowErrorId = 0;
this._sessionShowInfoId = 0;

this._sessionRequestTimeoutId = 0;
this._completed = false;
this._doneEmitted = false;

this.connect('closed', this._onDialogClosed.bind(this));

let title = _("Authentication Required");
Expand Down Expand Up @@ -259,8 +268,6 @@ var AuthenticationDialog = GObject.registerClass({
});

this.contentLayout.add_child(bodyContent);

this._doneEmitted = false;
}

_onUserComboClicked() {
Expand Down Expand Up @@ -427,14 +434,22 @@ var AuthenticationDialog = GObject.registerClass({
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._sessionCompletedId > 0) {
this._session.disconnect(this._sessionCompletedId);
this._session.disconnect(this._sessionRequestId);
this._session.disconnect(this._sessionShowErrorId);
this._session.disconnect(this._sessionShowInfoId);

this._sessionCompletedId = 0;
this._sessionRequestId = 0;
this._sessionShowErrorId = 0;
this._sessionShowInfoId = 0;
}

this._session = null;
}

if (this._sessionRequestTimeoutId) {
if (this._sessionRequestTimeoutId > 0) {
GLib.source_remove(this._sessionRequestTimeoutId);
this._sessionRequestTimeoutId = 0;
}
Expand Down

0 comments on commit 4c4bd53

Please sign in to comment.