Skip to content

Commit

Permalink
Ensure using latest reference to Main.panel.statusArea.quickSettings
Browse files Browse the repository at this point in the history
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/[email protected]/extension.js:348:9
    enable/this._enableTimeoutId<@file:///home/linolium/.local/share/gnome-shell/extensions/[email protected]/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.
  • Loading branch information
jkitching committed Apr 19, 2024
1 parent 6cbe412 commit 17aa065
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 17aa065

Please sign in to comment.