fix(sway/language): apply CSS classes on the main thread to stop SIGSEGV
set_current_layout() mutated label_'s GTK style context (remove_class/ add_class) while being called from the sway IPC worker thread via onEvent(). Off-main-thread GTK widget mutation caused a SIGSEGV. Record only the target layout in set_current_layout() and apply the matching CSS class in update(), which the dispatcher runs on the GTK main thread. A new applied_class_ member tracks the currently applied class so update() can swap it. The shared layout_/applied_class_ state is guarded by the existing mutex_. Fixes #3702.
This commit is contained in:
@@ -54,6 +54,9 @@ class Language : public ALabel, public sigc::trackable {
|
||||
const static std::string XKB_ACTIVE_LAYOUT_NAME_KEY;
|
||||
|
||||
Layout layout_;
|
||||
// CSS class currently applied to label_. Tracked so update() (main thread) can swap classes
|
||||
// instead of set_current_layout() mutating the widget from the IPC worker thread (#3702).
|
||||
std::string applied_class_;
|
||||
std::string tooltip_format_ = "";
|
||||
std::map<std::string, Layout> layouts_map_;
|
||||
bool hide_single_;
|
||||
|
||||
Reference in New Issue
Block a user