[polari/wip/fmuellner/invalid-object-access] connectionsList: Disconnect signals on destroy
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/invalid-object-access] connectionsList: Disconnect signals on destroy
- Date: Sun, 10 Dec 2017 15:02:39 +0000 (UTC)
commit 98077d45f99b072b7bba11739e48d0d3991429c9
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Dec 10 15:56:48 2017 +0100
connectionsList: Disconnect signals on destroy
Both AccountsMonitor and NetworksManager are singletons, so we need
to disconnect any signals to avoid accessing invalidated objects
after the list is destroyed.
https://gitlab.gnome.org/GNOME/polari/issues/32
src/connections.js | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index 5d04388..2b37951 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -112,17 +112,26 @@ var ConnectionsList = GObject.registerClass({
this._list.set_placeholder(placeholder);
this._accountsMonitor = AccountsMonitor.getDefault();
- this._accountsMonitor.connect('account-added', (mon, account) => {
- this._setAccountRowSensitive(account, false);
- });
- this._accountsMonitor.connect('account-removed', (mon, account) => {
- this._setAccountRowSensitive(account, true);
- });
+ let accountAddedId =
+ this._accountsMonitor.connect('account-added', (mon, account) => {
+ this._setAccountRowSensitive(account, false);
+ });
+ let accountRemovedId =
+ this._accountsMonitor.connect('account-removed', (mon, account) => {
+ this._setAccountRowSensitive(account, true);
+ });
this._networksManager = NetworksManager.getDefault();
- this._networksManager.connect('changed',
- this._networksChanged.bind(this));
+ let networksChangedId =
+ this._networksManager.connect('changed',
+ this._networksChanged.bind(this));
this._networksChanged();
+
+ this.connect('destroy', () => {
+ this._accountsMonitor.disconnect(accountAddedId);
+ this._accountsMonitor.disconnect(accountRemovedId);
+ this._networksManager.disconnect(networksChangedId);
+ });
}
get favorites_only() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]