fix(core): don't floor an explicit interval:0 to 1ms

std::max(1L, interval*1000) turned a user's explicit "interval": 0 into a
1ms periodic refresh, i.e. a ~1000x/s busy loop that starves the GTK main
loop and leaks memory (mpris RSS growth, missing tooltips, frozen updates).
An explicit 0 now stays the 'no periodic refresh' sentinel. Fixes #4987,
#4842; helps #4864, #4917, #4998, #5145.
This commit is contained in:
Alex
2026-07-04 03:09:20 +02:00
parent 4eb2513cc0
commit b5842d4f53
+8 -2
View File
@@ -25,8 +25,14 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
? std::chrono::milliseconds::max() ? std::chrono::milliseconds::max()
: std::chrono::milliseconds( : std::chrono::milliseconds(
(config_["interval"].isNumeric() (config_["interval"].isNumeric()
? std::max(1L, // Minimum 1ms due to millisecond precision ? (config_["interval"].asDouble() > 0
static_cast<long>(config_["interval"].asDouble() * 1000)) // Minimum 1ms due to millisecond precision
? std::max(1L, static_cast<long>(
config_["interval"].asDouble() * 1000))
// An explicit interval of 0 means "no periodic refresh"
// (event-driven only). Flooring it to 1ms busy-loops the
// main thread; keep it as the 0 sentinel (see custom.cpp).
: 0L)
: 1000 * (long)interval))), : 1000 * (long)interval))),
default_format_(format_) { default_format_(format_) {
label_.set_name(name); label_.set_name(name);