From 384c12a896fb09f690799dd1079b57996a2b820f Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sun, 5 Feb 2017 13:37:13 +0100 Subject: [PATCH] fix(xwindow): Lock mutexes on update #416 --- include/modules/meta/static_module.hpp | 1 - src/modules/xwindow.cpp | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/modules/meta/static_module.hpp b/include/modules/meta/static_module.hpp index 9b95ae7e..cc30e8fa 100644 --- a/include/modules/meta/static_module.hpp +++ b/include/modules/meta/static_module.hpp @@ -13,7 +13,6 @@ namespace modules { void start() { this->m_mainthread = thread([&] { this->m_log.trace("%s: Thread id = %i", this->name(), concurrency_util::thread_id(this_thread::get_id())); - std::unique_lock guard(this->m_updatelock); CAST_MOD(Impl)->update(); CAST_MOD(Impl)->broadcast(); }); diff --git a/src/modules/xwindow.cpp b/src/modules/xwindow.cpp index b1bfbdef..e49db956 100644 --- a/src/modules/xwindow.cpp +++ b/src/modules/xwindow.cpp @@ -96,12 +96,18 @@ namespace modules { } else { return; } + + broadcast(); } /** * Update the currently active window and query its title */ void xwindow_module::update(bool force) { + std::lock(m_buildlock, m_updatelock); + std::lock_guard guard_a(m_buildlock, std::adopt_lock); + std::lock_guard guard_b(m_updatelock, std::adopt_lock); + xcb_window_t win; if (force) { @@ -116,8 +122,6 @@ namespace modules { m_label->reset_tokens(); m_label->replace_token("%title%", m_active ? m_active->title() : ""); } - - broadcast(); } /**