From d854d71111a537220435da0c6a26af705186c54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 29 Dec 2014 10:26:01 +0100 Subject: [PATCH] PowerStatus: hide obviously invalid probes. * When we get bogus values back as the current battery state, there is little reason to present this to the user when we can detect it. * While it would be nice to solve the underlying bug, too (if there is one, this should make the new low battery notification feature a lot nicer in practice. --- src/apps/powerstatus/PowerStatusView.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/apps/powerstatus/PowerStatusView.cpp b/src/apps/powerstatus/PowerStatusView.cpp index f33aa00254..7c209e3f48 100644 --- a/src/apps/powerstatus/PowerStatusView.cpp +++ b/src/apps/powerstatus/PowerStatusView.cpp @@ -351,6 +351,15 @@ PowerStatusView::Update(bool force) fTimeLeft = -1; } + if (fOnline && (fPercent <= 0 || fPercent > 100)) { + // Just ignore this probe -- it obviously returned invalid values + fPercent = previousPercent; + fTimeLeft = previousTimeLeft; + fOnline = wasOnline; + fHasBattery = hadBattery; + return; + } + if (fInDeskbar) { // make sure the tray icon is large enough float width = fShowStatusIcon ? kMinIconWidth + 2 : 0;