mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix(sway): resolve destruction dependency between Ipc and SleeperThread
Ipc destructor closes socket and thus wakes up SleeperThread which was waiting for socket data in Ipc::handleEvent. Ipc::handleEvent then proceeds with sending signal to already destroyed object, causing heap-use-after-free Address Sanitizer error.
This commit is contained in:
@ -11,7 +11,13 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
// Get Initial focused window
|
||||
getTree();
|
||||
// Launch worker
|
||||
worker();
|
||||
ipc_.setWorker([this] {
|
||||
try {
|
||||
ipc_.handleEvent();
|
||||
} catch (const std::exception& e) {
|
||||
spdlog::error("Window: {}", e.what());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Window::onEvent(const struct Ipc::ipc_response& res) { getTree(); }
|
||||
@ -28,16 +34,6 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window::worker() {
|
||||
thread_ = [this] {
|
||||
try {
|
||||
ipc_.handleEvent();
|
||||
} catch (const std::exception& e) {
|
||||
spdlog::error("Window: {}", e.what());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
auto Window::update() -> void {
|
||||
if (!old_app_id_.empty()) {
|
||||
bar_.window.get_style_context()->remove_class(old_app_id_);
|
||||
|
Reference in New Issue
Block a user