From 18c7ad0026d5f1c6c14547fb9531506c7e68bb8d Mon Sep 17 00:00:00 2001 From: Alexis Date: Mon, 13 Aug 2018 23:43:35 +0200 Subject: [PATCH] fix(workspaces): lock mutex inside click callback --- src/modules/workspaces.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/workspaces.cpp b/src/modules/workspaces.cpp index 115cf4f6..34ff7bd3 100644 --- a/src/modules/workspaces.cpp +++ b/src/modules/workspaces.cpp @@ -20,8 +20,8 @@ waybar::modules::Workspaces::Workspaces(Bar &bar) } else ipc_recv_response(_ipcEventfd); uint32_t len = 0; - auto str = ipc_single_command(_ipcfd, IPC_GET_WORKSPACES, nullptr, &len); std::lock_guard lock(_mutex); + auto str = ipc_single_command(_ipcfd, IPC_GET_WORKSPACES, nullptr, &len); _workspaces = _getWorkspaces(str); Glib::signal_idle().connect_once(sigc::mem_fun(*this, &Workspaces::update)); } catch (const std::exception& e) { @@ -72,6 +72,7 @@ void waybar::modules::Workspaces::_addWorkspace(Json::Value node) button.set_relief(Gtk::RELIEF_NONE); button.signal_clicked().connect([this, pair] { try { + std::lock_guard lock(_mutex); auto value = fmt::format("workspace \"{}\"", pair.first->first); uint32_t size = value.size(); ipc_single_command(_ipcfd, IPC_COMMAND, value.c_str(), &size);