fix(hyprland/language): apply the CSS class on the main thread

onEvent() runs on the Hyprland IPC listener thread and mutated the label's
style context (add/remove class) directly, racing the GTK main thread's
drawing and corrupting the heap (double free / corrupted double-linked list).
Follow the Submap pattern: onEvent only stores the layout under the mutex and
emits the dispatcher; update() swaps the CSS class on the main thread, tracking
the previously applied class.

Fixes #4665
This commit is contained in:
Alex
2026-07-05 23:06:37 +02:00
parent 6c1a0fa185
commit 6294ed2520
2 changed files with 14 additions and 15 deletions
+1 -2
View File
@@ -30,8 +30,6 @@ class Language : public waybar::ALabel, public EventHandler {
std::string short_description;
};
auto removeXkbLayoutCssClass() -> void;
auto addXkbLayoutCssClass() -> void;
static auto getLayout(const std::string&) -> Layout;
std::mutex mutex_;
@@ -39,6 +37,7 @@ class Language : public waybar::ALabel, public EventHandler {
util::JsonParser parser_;
Layout layout_;
std::string prev_short_name_; // applied CSS class; touched only in update() (#4665)
IPC& m_ipc;
};