diff --git a/src/background.cpp b/src/background.cpp index bfec8ea..7162a41 100644 --- a/src/background.cpp +++ b/src/background.cpp @@ -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) { diff --git a/src/battery.cpp b/src/battery.cpp index 404f90f..5c9b6be 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -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() diff --git a/src/battery.h b/src/battery.h index 90d7ea0..443bb9f 100644 --- a/src/battery.h +++ b/src/battery.h @@ -17,7 +17,7 @@ public: /** * Gets the icon that reflects the current battery status. */ - OffscreenSurface const& getIcon(); + const OffscreenSurface *getIcon(); private: void update();