fix(clock): crash on scrolling with local timezone (`""`) in the list

While we at it, eliminate use of non-portable GCC conditional expression
syntax. There are no significant side-effects that would justify use of
the language extension.
pull/2940/head
Aleksei Bavshin 2024-02-19 20:58:09 -08:00
parent ce5a1cf2f9
commit a2deff3689
No known key found for this signature in database
GPG Key ID: 4F071603387A382A
1 changed files with 3 additions and 2 deletions

View File

@ -130,7 +130,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
}
auto waybar::modules::Clock::update() -> void {
auto tz{tzList_[tzCurrIdx_] ?: current_zone()};
const auto* tz = tzList_[tzCurrIdx_] != nullptr ? tzList_[tzCurrIdx_] : current_zone();
const zoned_time now{tz, floor<seconds>(system_clock::now())};
label_.set_markup(fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(now)));
@ -167,7 +167,8 @@ auto waybar::modules::Clock::getTZtext(sys_seconds now) -> std::string {
std::stringstream os;
for (size_t tz_idx{0}; tz_idx < tzList_.size(); ++tz_idx) {
if (static_cast<int>(tz_idx) == tzCurrIdx_) continue;
auto zt{zoned_time{tzList_[tz_idx], now}};
const auto* tz = tzList_[tz_idx] != nullptr ? tzList_[tz_idx] : current_zone();
auto zt{zoned_time{tz, now}};
os << fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(zt)) << '\n';
}