Commit Graph
6 Commits
Author SHA1 Message Date
Jason Chiu 1facd4ef95 Update tray.cpp 2026-07-04 01:34:00 +02:00
Jason Chiu 87a337ecdf Update tray.hpp 2026-07-04 01:31:39 +02:00
Jason Chiu 2d9fee144e Update privacy.cpp 2026-06-09 06:51:14 +00:00
Jason Chiu 2506196274 Update privacy.hpp 2026-06-09 06:49:41 +00:00
Jason Chiu fb829c8a8e ## fix(niri/workspaces): crash (segfault) when setting workspace button markup
### Problem
Waybar segfaults on startup when `niri/workspaces` is the only configured
module (default options). Right after the first `WorkspacesChanged` event:
 
    Thread 1 "waybar" received signal SIGSEGV
    #0 gtk_label_set_markup ()
    #1 waybar::modules::niri::Workspaces::doUpdate () at src/modules/niri/workspaces.cpp:106
 
### Root cause
[doUpdate()](cci:1://file:///home/lj/Downloads/Waybar/src/modules/niri/window.cpp:27:0-90:1) set the label markup via:
 
    static_cast<Gtk::Label*>(button.get_children()[0])->set_markup(name);
 
The button's child *is* a valid `GtkLabel`, but gtkmm's `get_children()`
returns it wrapped as a generic `Gtk::Widget` (confirmed: `dynamic_cast`
to `Gtk::Label*` yields `nullptr`). The unchecked `static_cast` then
performs an invalid downcast, producing a corrupt pointer whose `gobj()`
is garbage (`0x1`), so `gtk_label_set_markup()` dereferences it and crashes.
 
This is reliably triggered when no other module has instantiated a
`Gtk::Label` yet (so the `Gtk::Label` wrapper isn't registered), which is
exactly the case for a `niri/workspaces`-only bar. The same idiom exists in
`sway/workspaces` and `wayfire/workspaces`; it's masked there because typical
configs include other label-using modules.

### Testing
- Reproduced the crash on 0.15.0 / current `master` with a minimal
  `"modules-left": ["niri/workspaces"]` config under niri.
- After the fix: no crash; three workspace buttons render with correct
  names/labels (`niri-workspace-1/2/3`).
2026-06-09 06:20:05 +00:00
Jason Chiu eee0362367 Fix clang build error 2025-09-17 22:09:49 +00:00