Skip to content

Commit b994a16

Browse files
committed
Apply gnome-extension-reviewer recommendations
1 parent 01b63a1 commit b994a16

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

extension.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class FedoraUpdateIndicator extends Button {
194194

195195
// Load settings
196196
this._settings = this._extension.getSettings();
197-
this._settings.connect('changed', this._positionChanged.bind(this));
197+
this._settingsPositionChangedId = this._settings.connect('changed', this._positionChanged.bind(this));
198198
this._settingsChangedId = this._settings.connect('changed', this._applySettings.bind(this));
199199
this._applySettings();
200200

@@ -305,12 +305,30 @@ class FedoraUpdateIndicator extends Button {
305305

306306
destroy() {
307307
console.log(`Fedora-update : unloading`);
308-
this._settings.disconnect( this._settingsChangedId );
308+
if (this.monitor) {
309+
if (this._monitorChangedId) {
310+
this.monitor.disconnect(this._monitorChangedId);
311+
this._monitorChangedId = null;
312+
}
313+
this.monitor.cancel?.();
314+
this.monitor = null;
315+
}
316+
if (this._settings) {
317+
if (this._settingsPositionChangedId) {
318+
this._settings.disconnect(this._settingsPositionChangedId);
319+
this._settingsPositionChangedId = null;
320+
}
321+
322+
if (this._settingsChangedId) {
323+
this._settings.disconnect(this._settingsChangedId);
324+
this._settingsChangedId = null;
325+
}
326+
}
309327
if (this._notifSource) {
310328
// Delete the notification source, which lay still have a notification shown
311329
this._notifSource.destroy();
312330
this._notifSource = null;
313-
};
331+
}
314332
if (this.monitor) {
315333
// Stop spying on package manager local dir
316334
this.monitor.cancel();
@@ -378,7 +396,7 @@ class FedoraUpdateIndicator extends Button {
378396
this.monitoring = PACKAGE_CACHE_DIR;
379397
this.packages_dir = Gio.file_new_for_path(PACKAGE_CACHE_DIR);
380398
this.monitor = this.packages_dir.monitor_directory(0, null);
381-
this.monitor.connect('changed', this._onFolderChanged.bind(this));
399+
this._monitorChangedId = this.monitor.connect('changed', this._onFolderChanged.bind(this));
382400
}
383401
}
384402

0 commit comments

Comments
 (0)