fix(battery): Safety check
Make sure returned label is valid before access. Refs #318
This commit is contained in:
parent
30201bac38
commit
d7d0fbcae4
@ -198,12 +198,14 @@ namespace modules {
|
|||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
if (label) {
|
||||||
label->reset_tokens();
|
label->reset_tokens();
|
||||||
label->replace_token("%percentage%", to_string(m_percentage) + "%");
|
label->replace_token("%percentage%", to_string(m_percentage) + "%");
|
||||||
|
|
||||||
if (m_state != battery_module::state::FULL && !m_timeformat.empty()) {
|
if (m_state != battery_module::state::FULL && !m_timeformat.empty()) {
|
||||||
label->replace_token("%time%", current_time());
|
label->replace_token("%time%", current_time());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user