fix(hyprland/workspaces): own debounce timer on main thread, fix UAF

The debounce timer added for flicker prevention was armed from the IPC
listener thread via Glib::signal_timeout().connect(), while its timeout
lambda and the m_updatePending flag ran on the GTK main thread — an
unsynchronized cross-thread data race on GLib timer/main-loop state.
Additionally ~Workspaces() never disconnected the timer, so a pending
timeout could fire on a freed 'this' (use-after-free).

Restore the pre-refactor threading model: onEvent now only mutates state
under m_mutex on the IPC thread and calls dp.emit() (Glib::Dispatcher is
thread-safe). The debounce timer is owned entirely by the main-thread
update() path, which arms/re-arms it on each dispatch and coalesces
bursts into a single refresh. ~Workspaces() disconnects the timer
(guarded) so none outlives the object. Debounce behavior is preserved.
This commit is contained in:
Alex
2026-07-05 10:13:24 +02:00
parent 4764a62afc
commit 30dcd7a7ca
2 changed files with 26 additions and 20 deletions
+2 -1
View File
@@ -227,8 +227,9 @@ class Workspaces : public AModule, public EventHandler {
sigc::connection m_scrollEventConnection_;
IPC& m_ipc;
// Coalesces bursts of Hyprland events into a single UI refresh. Armed and
// disconnected only on the GTK main thread (see Workspaces::update).
sigc::connection m_debounceTimer;
bool m_updatePending = false;
};
} // namespace waybar::modules::hyprland