mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 07:29:44 +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,
|
s.width() / 2, gmenu2x.bottomBarTextY,
|
||||||
Font::HAlignCenter, Font::VAlignMiddle);
|
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) {
|
bool Background::handleButtonPress(InputManager::Button button) {
|
||||||
|
@ -53,7 +53,7 @@ Battery::Battery(SurfaceCollection& sc_)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
OffscreenSurface const& Battery::getIcon()
|
const OffscreenSurface *Battery::getIcon()
|
||||||
{
|
{
|
||||||
// Check battery status every 60 seconds.
|
// Check battery status every 60 seconds.
|
||||||
unsigned int now = SDL_GetTicks();
|
unsigned int now = SDL_GetTicks();
|
||||||
@ -62,7 +62,7 @@ OffscreenSurface const& Battery::getIcon()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
return *sc.skinRes(iconPath);
|
return sc.skinRes(iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::update()
|
void Battery::update()
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Gets the icon that reflects the current battery status.
|
* Gets the icon that reflects the current battery status.
|
||||||
*/
|
*/
|
||||||
OffscreenSurface const& getIcon();
|
const OffscreenSurface *getIcon();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update();
|
void update();
|
||||||
|
Loading…
Reference in New Issue
Block a user