mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 06:39:41 +02:00
Don't crash if battery icon is not found
The icon pointer can be null, so don't convert it to a reference.
This commit is contained in:
parent
9cfbc56bfa
commit
05a58e869c
@ -22,7 +22,10 @@ void Background::paint(Surface& s) {
|
||||
s.width() / 2, gmenu2x.bottomBarTextY,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
|
||||
battery.getIcon().blit(s, s.width() - 19, gmenu2x.bottomBarIconY);
|
||||
auto icon = battery.getIcon();
|
||||
if (icon) {
|
||||
icon->blit(s, s.width() - 19, gmenu2x.bottomBarIconY);
|
||||
}
|
||||
}
|
||||
|
||||
bool Background::handleButtonPress(InputManager::Button button) {
|
||||
|
@ -53,7 +53,7 @@ Battery::Battery(SurfaceCollection& sc_)
|
||||
update();
|
||||
}
|
||||
|
||||
OffscreenSurface const& Battery::getIcon()
|
||||
const OffscreenSurface *Battery::getIcon()
|
||||
{
|
||||
// Check battery status every 60 seconds.
|
||||
unsigned int now = SDL_GetTicks();
|
||||
@ -62,7 +62,7 @@ OffscreenSurface const& Battery::getIcon()
|
||||
update();
|
||||
}
|
||||
|
||||
return *sc.skinRes(iconPath);
|
||||
return sc.skinRes(iconPath);
|
||||
}
|
||||
|
||||
void Battery::update()
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
/**
|
||||
* Gets the icon that reflects the current battery status.
|
||||
*/
|
||||
OffscreenSurface const& getIcon();
|
||||
const OffscreenSurface *getIcon();
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
Loading…
Reference in New Issue
Block a user