authPrompt: Manually destroy inactive/unused entry

AuthPrompt creates two entries, one for text and one for passwords, but
only ever one is used as child widget. This would lead to the other one
not getting destroyed when the the AuthPrompt is destroyed.

This now manually destroys the inactive one when the AuthPrompt is
destroyed to avoid that leak.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6395
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2637>
This commit is contained in:
Sebastian Keller 2023-02-12 18:13:59 +01:00 committed by Marge Bot
parent 2e51e7f887
commit 572d011894

View File

@ -120,6 +120,8 @@ var AuthPrompt = GObject.registerClass({
}
_onDestroy() {
this._inactiveEntry.destroy();
this._inactiveEntry = null;
this._userVerifier.destroy();
this._userVerifier = null;
}
@ -189,6 +191,7 @@ var AuthPrompt = GObject.registerClass({
this._entry = this._passwordEntry;
this._mainBox.add_child(this._entry);
this._entry.grab_key_focus();
this._inactiveEntry = this._textEntry;
this._timedLoginIndicator = new St.Bin({
style_class: 'login-dialog-timed-login-indicator',
@ -278,9 +281,11 @@ var AuthPrompt = GObject.registerClass({
if (secret && this._entry !== this._passwordEntry) {
this._mainBox.replace_child(this._entry, this._passwordEntry);
this._entry = this._passwordEntry;
this._inactiveEntry = this._textEntry;
} else if (!secret && this._entry !== this._textEntry) {
this._mainBox.replace_child(this._entry, this._textEntry);
this._entry = this._textEntry;
this._inactiveEntry = this._passwordEntry;
}
this._capsLockWarningLabel.visible = secret;
}