nwg-piotr / nwg-panel

GTK3-based panel for sway and Hyprland Wayland compositors
MIT License
624 stars 42 forks source link

[BUG] Crash with UnboundLocalError #142

Closed OlivierNicole closed 2 years ago

OlivierNicole commented 2 years ago

Describe the bug

The program crashed, I believe it was when plugging in an external screen. Sorry once again I don't have a reliable way to reproduce.

Output:

Dependencies check: {'light': True, 'brightnessctl': False, 'ddcutil': False, 'pamixer': True, 'pactl': True, 'playerctl': False, 'netifaces': True, 'btmgmt': True, 'wlr-randr': True, 'upower': True, 'swaync': False, 'python-requests': True}
Running on sway
Traceback (most recent call last):
  File "/nix/store/9av6qlv4c0phil0sjsqi2jy8mmh9za95-nwg-panel-0.7.4/bin/.nwg-panel-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/9av6qlv4c0phil0sjsqi2jy8mmh9za95-nwg-panel-0.7.4/lib/python3.9/site-packages/nwg_panel/main.py", line 543, in main
    instantiate_content(panel, left_box, panel["modules-left"], icons_path=icons_path)
  File "/nix/store/9av6qlv4c0phil0sjsqi2jy8mmh9za95-nwg-panel-0.7.4/lib/python3.9/site-packages/nwg_panel/main.py", line 171, in instantiate_content
    workspaces = SwayWorkspaces(panel["sway-workspaces"], common.i3, icons_path=icons_path)
  File "/nix/store/9av6qlv4c0phil0sjsqi2jy8mmh9za95-nwg-panel-0.7.4/lib/python3.9/site-packages/nwg_panel/modules/sway_workspaces.py", line 23, in __init__
    self.build_box()
  File "/nix/store/9av6qlv4c0phil0sjsqi2jy8mmh9za95-nwg-panel-0.7.4/lib/python3.9/site-packages/nwg_panel/modules/sway_workspaces.py", line 65, in build_box
    if num == str(ws_num) and self.settings["focused-labels"]:
UnboundLocalError: local variable 'ws_num' referenced before assignment

To Reproduce Steps to reproduce the behavior:

  1. Plug an external screen after laptop resume.
  2. Sometimes nwg-panel will crash with the message above.

Expected behavior It should not crash.

Desktop (please complete the following information):

nwg-piotr commented 2 years ago

Hope it's going to help. Thanks for reporting the issue.

OlivierNicole commented 1 year ago

Haven't had the crash in a month, so this seems fixed. Thanks!