mirror of
https://github.com/polybar/polybar.git
synced 2026-03-09 01:37:30 +00:00
fix(timer_module): Ensure that interval > 0 (#2274)
Since 3.5.0, we use m_interval for a modulo operation, this crashes the bar if the interval is 0. A non-positive interval shouldn't be allowed anyway, so we now throw an exception in that case. Fixes #2273
This commit is contained in:
@ -17,6 +17,20 @@ namespace modules {
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Loads and sets the interval for this module.
|
||||
*
|
||||
* Will throw an exception if a non-positive (<= 0) number is given.
|
||||
*/
|
||||
void set_interval(interval_t def) {
|
||||
m_interval = this->m_conf.template get<decltype(m_interval)>(this->name(), "interval", def);
|
||||
|
||||
if (m_interval <= 0s) {
|
||||
throw module_error(
|
||||
this->name() + ": 'interval' must be larger than 0 (got '" + to_string(m_interval.count()) + "s')");
|
||||
}
|
||||
}
|
||||
|
||||
void runner() {
|
||||
this->m_log.trace("%s: Thread id = %i", this->name(), concurrency_util::thread_id(this_thread::get_id()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user