mirror of
https://github.com/polybar/polybar.git
synced 2026-02-19 12:15:26 +00:00
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
31 lines
669 B
C++
31 lines
669 B
C++
#include "modules/counter.hpp"
|
|
|
|
#include "modules/meta/base.inl"
|
|
|
|
POLYBAR_NS
|
|
|
|
namespace modules {
|
|
template class module<counter_module>;
|
|
|
|
counter_module::counter_module(const bar_settings& bar, string name_)
|
|
: timer_module<counter_module>(bar, move(name_)) {
|
|
set_interval(1s);
|
|
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
|
|
}
|
|
|
|
bool counter_module::update() {
|
|
m_counter++;
|
|
return true;
|
|
}
|
|
|
|
bool counter_module::build(builder* builder, const string& tag) const {
|
|
if (tag == TAG_COUNTER) {
|
|
builder->node(to_string(m_counter));
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
} // namespace modules
|
|
|
|
POLYBAR_NS_END
|