From 17aa06525983e4ddc24f74f4c9897d565a3b972e Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Sat, 20 Apr 2024 01:23:07 +0800 Subject: [PATCH] Ensure using latest reference to Main.panel.statusArea.quickSettings While waiting for quickSettings._brightness, Main.panel.statusArea.quickSettings was previously be stored in a const. However, upon using Alt+F2 and "r" to initiate a restart of gnome-session, this sequence was observed: soft-brightness-plus: Brightness slider ready, continue enable procedure JS ERROR: TypeError: Main.panel.statusArea.quickSettings._brightness is undefined _enable@file:///home/linolium/.local/share/gnome-shell/extensions/soft-brightness-plus@joelkitching.com/extension.js:348:9 enable/this._enableTimeoutId<@file:///home/linolium/.local/share/gnome-shell/extensions/soft-brightness-plus@joelkitching.com/extension.js:320:22 @resource:///org/gnome/shell/ui/init.js:21:20 I do not believe this actually solves the issue, but could perhaps help in reasoning about the state of quickSettings across gnome-shell replacement restarts. A full solution may involve implementing retries whenever reading _brightness, or within the first N seconds of enabling the extension. --- src/extension.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/extension.js b/src/extension.js index 844fefe..7829675 100644 --- a/src/extension.js +++ b/src/extension.js @@ -312,10 +312,9 @@ class IndicatorManager { enable() { // Subsequent 100ms checks: Wait until the _brightness object has been // set on quickSettings. - const quickSettings = Main.panel.statusArea.quickSettings; let tries = 0; this._enableTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100, () => { - if (tries >= 0 && quickSettings._brightness !== null) { + if (tries >= 0 && Main.panel.statusArea.quickSettings._brightness !== null) { this._logger.log_debug('Brightness slider ready, continue enable procedure'); this._enableTimeoutId = null; this._enable();