Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -271,8 +271,10 @@ public: · 270 unmodified lines | ||
| 271 | 271 | while (!_quit) { |
| 272 | 272 | QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS); |
| 273 | 273 | auto now = usecTimestampNow(); |
| 274 | − auto lastHeartbeatAge = now - _heartbeat; | |
| 275 | − auto sinceLastReport = now - _lastReport; | |
| 274 | + | |
| 275 | + // in the unlikely event that now is less than _heartbeat, don't rollover and confuse ourselves | |
| 276 | + auto lastHeartbeatAge = (now > _heartbeat) ? now - _heartbeat : 0; | |
| 277 | + auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0; | |
| 276 | 278 | auto elapsedMovingAverage = _movingAverage.getAverage(); |
| 277 | 279 | |
| 278 | 280 | if (elapsedMovingAverage > _maxElapsedAverage) { |