refactor: execute update on idle

This commit is contained in:
Alex
2019-05-18 15:32:40 +02:00
parent 4865a9ad6c
commit aa385e28b6
2 changed files with 30 additions and 24 deletions

View File

@ -272,11 +272,14 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos) {
modules_right_.emplace_back(module);
}
module->dp.connect([module, &name] {
try {
module->update();
} catch (const std::exception& e) {
std::cerr << name.asString() + ": " + e.what() << std::endl;
}
// Fix https://github.com/Alexays/Waybar/issues/320, proper way?
Glib::signal_idle().connect_once([module, &name] {
try {
module->update();
} catch (const std::exception& e) {
std::cerr << name.asString() + ": " + e.what() << std::endl;
}
});
});
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;