mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-21 18:52:49 +00:00
Add nullptr check for batteryText
If SensorTooltips: true, then batteryText would be nullptr, but the class would still be updated, causing the crash Fixes https://github.com/scorpion-26/gBar/issues/58
This commit is contained in:
parent
4b3679b550
commit
8b8ce501d4
1 changed files with 5 additions and 2 deletions
|
@ -24,6 +24,7 @@ namespace Bar
|
|||
case Right: return Alignment::Right;
|
||||
case Center: return Alignment::Fill;
|
||||
}
|
||||
return Alignment::Right;
|
||||
}
|
||||
|
||||
TransitionType SideToDefaultTransition(Side side)
|
||||
|
@ -94,13 +95,15 @@ namespace Bar
|
|||
if (isCharging && !wasCharging && sensor.Get() != nullptr)
|
||||
{
|
||||
sensor.AddClass("battery-charging");
|
||||
batteryText->AddClass("battery-charging");
|
||||
if (batteryText)
|
||||
batteryText->AddClass("battery-charging");
|
||||
wasCharging = true;
|
||||
}
|
||||
else if (!isCharging && wasCharging)
|
||||
{
|
||||
sensor.RemoveClass("battery-charging");
|
||||
batteryText->RemoveClass("battery-charging");
|
||||
if (batteryText)
|
||||
batteryText->RemoveClass("battery-charging");
|
||||
wasCharging = false;
|
||||
}
|
||||
return TimerResult::Ok;
|
||||
|
|
Loading…
Reference in a new issue