fix(battery): Safety check
Make sure returned label is valid before access. Refs #318
This commit is contained in:
parent
30201bac38
commit
d7d0fbcae4
@ -198,11 +198,13 @@ namespace modules {
|
|||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
label->reset_tokens();
|
if (label) {
|
||||||
label->replace_token("%percentage%", to_string(m_percentage) + "%");
|
label->reset_tokens();
|
||||||
|
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