From dca6371d476518ff72d43af37f81d58ca42924d6 Mon Sep 17 00:00:00 2001 From: urhend Date: Sat, 1 Aug 2026 21:27:15 +0200 Subject: [PATCH] Remove this._destroyed lifecycle guard flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EGO reviewer feedback: this is the exact "Bad Practice" pattern the Extension Best Practices Guidelines calls out under Lifecycle and Destruction State — boolean flags like this._destroyed guarding against late-resolving callbacks aren't the correct fix. destroy() already does the right things in the right order (remove sources, disconnect signals, cancel, then super.destroy() last), which is what the guide asks for instead. runCommand()'s CANCELLED passthrough from proc.init() stays — that's unrelated, not a lifecycle flag, and makes cancellation actually propagate instead of being reported as a normal failure. --- extension.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/extension.js b/extension.js index 69612a5..e87fa92 100644 --- a/extension.js +++ b/extension.js @@ -174,7 +174,6 @@ const Indicator = GObject.registerClass( this._pingStatus = new Map(); this._previousCategory = null; this._connected = false; - this._destroyed = false; const iconPath = GLib.build_filenamev([ extensionPath, @@ -235,8 +234,6 @@ const Indicator = GObject.registerClass( return; } - if (this._destroyed) return; - const name = parseNetworkName(result.stdout); if (name) this._networkNameLabel.text = name; } @@ -281,7 +278,6 @@ const Indicator = GObject.registerClass( if (generation !== this._resourceGeneration) return; pingAddress(address, this._cancellable) .then((reachable) => { - if (this._destroyed) return; if (generation !== this._resourceGeneration) return; this._pingStatus.set(address, reachable); const dot = this._resourceDots.get(address); @@ -532,7 +528,6 @@ const Indicator = GObject.registerClass( } finally { this._busy = false; } - if (this._destroyed) return; this._scheduleQuickRefreshes(); } @@ -549,7 +544,6 @@ const Indicator = GObject.registerClass( } finally { this._busy = false; } - if (this._destroyed) return; this._scheduleQuickRefreshes(); } @@ -577,14 +571,11 @@ const Indicator = GObject.registerClass( ); } catch (e) { if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) return; - if (this._destroyed) return; this._setState("unknown"); this._maybeNotifyStateChange("unknown"); return; } - if (this._destroyed) return; - if (!result.success && result.stdout.length === 0) { this._setState("unknown"); this._maybeNotifyStateChange("unknown"); @@ -630,19 +621,14 @@ const Indicator = GObject.registerClass( ); } catch (e) { if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) return; - if (this._destroyed) return; this._setResources([]); return; } - if (this._destroyed) return; - this._setResources(parseResources(result.stdout)); } destroy() { - this._destroyed = true; - if (this._timeoutId) { GLib.Source.remove(this._timeoutId); this._timeoutId = null;