fix(battery): Safety check
Make sure returned label is valid before access. Refs #318
This commit is contained in:
parent
30201bac38
commit
d7d0fbcae4
1 changed files with 6 additions and 4 deletions
|
@ -198,11 +198,13 @@ namespace modules {
|
|||
}
|
||||
}();
|
||||
|
||||
label->reset_tokens();
|
||||
label->replace_token("%percentage%", to_string(m_percentage) + "%");
|
||||
if (label) {
|
||||
label->reset_tokens();
|
||||
label->replace_token("%percentage%", to_string(m_percentage) + "%");
|
||||
|
||||
if (m_state != battery_module::state::FULL && !m_timeformat.empty()) {
|
||||
label->replace_token("%time%", current_time());
|
||||
if (m_state != battery_module::state::FULL && !m_timeformat.empty()) {
|
||||
label->replace_token("%time%", current_time());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue