bug: fix overflow/underflow with graph timespan zoom (#1219)

* bug: fix overflow/underflow with graph timespan zoom

Basically, you could overflow/underflow the time span which would skip
checks.

* changelog
This commit is contained in:
Clement Tsang 2023-06-21 04:03:48 +00:00 committed by GitHub
parent 76e81df715
commit 6f1a8f7e5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 13 deletions

View file

@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Bug Fixes
- [https://github.com/ClementTsang/bottom/pull/1216](https://github.com/ClementTsang/bottom/pull/1216): Fix arguments not being sorted alphabetically.
- [#1216](https://github.com/ClementTsang/bottom/pull/1216): Fix arguments not being sorted alphabetically.
- [#1219](https://github.com/ClementTsang/bottom/pull/1219): Fix overflow/underflow in graph timespan zoom.
## [0.9.2] - 2023-06-11

View file

@ -2173,8 +2173,10 @@ impl App {
.widget_states
.get_mut(&self.current_widget.widget_id)
{
let new_time = cpu_widget_state.current_display_time
+ self.app_config_fields.time_interval;
let new_time = cpu_widget_state
.current_display_time
.saturating_add(self.app_config_fields.time_interval);
if new_time <= self.app_config_fields.retention_ms {
cpu_widget_state.current_display_time = new_time;
self.states.cpu_state.force_update = Some(self.current_widget.widget_id);
@ -2199,8 +2201,10 @@ impl App {
.widget_states
.get_mut(&self.current_widget.widget_id)
{
let new_time = mem_widget_state.current_display_time
+ self.app_config_fields.time_interval;
let new_time = mem_widget_state
.current_display_time
.saturating_add(self.app_config_fields.time_interval);
if new_time <= self.app_config_fields.retention_ms {
mem_widget_state.current_display_time = new_time;
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
@ -2225,8 +2229,10 @@ impl App {
.widget_states
.get_mut(&self.current_widget.widget_id)
{
let new_time = net_widget_state.current_display_time
+ self.app_config_fields.time_interval;
let new_time = net_widget_state
.current_display_time
.saturating_add(self.app_config_fields.time_interval);
if new_time <= self.app_config_fields.retention_ms {
net_widget_state.current_display_time = new_time;
self.states.net_state.force_update = Some(self.current_widget.widget_id);
@ -2257,8 +2263,10 @@ impl App {
.widget_states
.get_mut(&self.current_widget.widget_id)
{
let new_time = cpu_widget_state.current_display_time
- self.app_config_fields.time_interval;
let new_time = cpu_widget_state
.current_display_time
.saturating_sub(self.app_config_fields.time_interval);
if new_time >= constants::STALE_MIN_MILLISECONDS {
cpu_widget_state.current_display_time = new_time;
self.states.cpu_state.force_update = Some(self.current_widget.widget_id);
@ -2283,8 +2291,10 @@ impl App {
.widget_states
.get_mut(&self.current_widget.widget_id)
{
let new_time = mem_widget_state.current_display_time
- self.app_config_fields.time_interval;
let new_time = mem_widget_state
.current_display_time
.saturating_sub(self.app_config_fields.time_interval);
if new_time >= constants::STALE_MIN_MILLISECONDS {
mem_widget_state.current_display_time = new_time;
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
@ -2309,8 +2319,10 @@ impl App {
.widget_states
.get_mut(&self.current_widget.widget_id)
{
let new_time = net_widget_state.current_display_time
- self.app_config_fields.time_interval;
let new_time = net_widget_state
.current_display_time
.saturating_sub(self.app_config_fields.time_interval);
if new_time >= constants::STALE_MIN_MILLISECONDS {
net_widget_state.current_display_time = new_time;
self.states.net_state.force_update = Some(self.current_widget.widget_id);