fix(xwindow): Lock mutexes on update #416

This commit is contained in:
Michael Carlberg 2017-02-05 13:37:13 +01:00
parent 107bdb91e3
commit 384c12a896
2 changed files with 6 additions and 3 deletions

View File

@ -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<std::mutex> guard(this->m_updatelock);
CAST_MOD(Impl)->update();
CAST_MOD(Impl)->broadcast();
});

View File

@ -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<std::mutex> guard_a(m_buildlock, std::adopt_lock);
std::lock_guard<std::mutex> 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();
}
/**