From b0a016e90a4b92d2a75ab40befa8d40b734cc1d5 Mon Sep 17 00:00:00 2001 From: Benjamin Vaisvil Date: Sun, 24 Nov 2024 18:01:39 -0600 Subject: [PATCH 1/4] We should check if the graphics device exists in the current layout before removing it and recalculating the heights of the sections. If we do not do this the users who do not have graphics devices will always have their height preferences ignored since an assumption was made that the graphics device existed in the layout. Closes issue #153 --- src/renderer/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 90f0829..a2368fc 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -248,7 +248,11 @@ impl<'a> TerminalRenderer<'_> { let mut section_geometry = section_geometry.to_vec(); let mut recompute_constraints_on_start_up = false; app.update_gfx_devices(); - if app.gfx_devices.is_empty() { + if app.gfx_devices.is_empty() + && section_geometry + .iter() + .any(|(s, _)| *s == Section::Graphics) + { section_geometry.retain(|(section, _)| *section != Section::Graphics); recompute_constraints_on_start_up = true; } From 534593ab2ef7c5a98c36bb80aca10648cd8406b8 Mon Sep 17 00:00:00 2001 From: Benjamin Vaisvil Date: Sun, 24 Nov 2024 18:35:48 -0600 Subject: [PATCH 2/4] Some lint fixes --- src/metrics/graphics/device.rs | 2 ++ src/metrics/graphics/graphics_none.rs | 1 + src/metrics/mod.rs | 5 +++-- src/metrics/zprocess.rs | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/metrics/graphics/device.rs b/src/metrics/graphics/device.rs index c3b4b32..e69ecbc 100644 --- a/src/metrics/graphics/device.rs +++ b/src/metrics/graphics/device.rs @@ -4,10 +4,12 @@ pub trait GraphicsExt { fn update_gfx_devices(&mut self); + #[allow(dead_code)] fn update_total(&mut self, total: Option); fn update_gpu_utilization(&mut self); } +#[allow(dead_code)] #[derive(Clone)] pub struct GraphicsDeviceProcess { pub pid: i32, diff --git a/src/metrics/graphics/graphics_none.rs b/src/metrics/graphics/graphics_none.rs index 9a52e53..498c330 100644 --- a/src/metrics/graphics/graphics_none.rs +++ b/src/metrics/graphics/graphics_none.rs @@ -7,6 +7,7 @@ use crate::metrics::CPUTimeApp; impl GraphicsExt for CPUTimeApp { fn update_gfx_devices(&mut self) {} + #[allow(unused_variables, unused_mut)] fn update_total(&mut self, mut total: Option) {} fn update_gpu_utilization(&mut self) {} } diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs index 2e318db..ea419e6 100644 --- a/src/metrics/mod.rs +++ b/src/metrics/mod.rs @@ -117,6 +117,7 @@ pub enum ProcessTableSortOrder { } pub trait DiskFreeSpaceExt { + #[allow(dead_code)] fn get_perc_free_space(&self) -> f32; } @@ -128,13 +129,13 @@ impl DiskFreeSpaceExt for Disk { percent_of(self.get_available_space(), self.get_total_space()) } } - +#[allow(dead_code)] pub struct NetworkInterface { pub name: String, pub ip: String, pub dest: String, } - +#[allow(dead_code)] pub struct Sensor { pub name: String, pub current_temp: f32, diff --git a/src/metrics/zprocess.rs b/src/metrics/zprocess.rs index 90771ed..b6929ed 100644 --- a/src/metrics/zprocess.rs +++ b/src/metrics/zprocess.rs @@ -41,6 +41,7 @@ macro_rules! convert_error_to_string { }; } +#[allow(dead_code)] #[derive(Clone)] pub struct ZProcess { pub pid: i32, From 23de34d16a86fd517cce16e1e285423cbae85a2f Mon Sep 17 00:00:00 2001 From: Benjamin Vaisvil Date: Sun, 24 Nov 2024 18:38:13 -0600 Subject: [PATCH 3/4] Migrated from PanicHook to PanicHookInfo --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 68abe87..6ed91dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,13 +31,13 @@ use std::error::Error; use std::fs; use std::io::stdout; use std::panic; -use std::panic::PanicInfo; +use std::panic::PanicHookInfo; use std::path::Path; use std::process::exit; use std::time::Duration; use std::time::SystemTime; -fn panic_hook(info: &PanicInfo<'_>) { +fn panic_hook(info: &PanicHookInfo<'_>) { let location = info.location().unwrap(); // The current implementation always returns Some let msg = match info.payload().downcast_ref::<&'static str>() { Some(s) => *s, From 0ca44b59e2c983c775643ed980a2a1e9fbfc81a1 Mon Sep 17 00:00:00 2001 From: Benjamin Vaisvil Date: Sun, 24 Nov 2024 18:39:36 -0600 Subject: [PATCH 4/4] silenced another lint --- src/metrics/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs index ea419e6..f0237d8 100644 --- a/src/metrics/mod.rs +++ b/src/metrics/mod.rs @@ -220,6 +220,7 @@ impl Top { } } +#[allow(dead_code)] pub struct CPUTimeApp { pub histogram_map: HistogramMap, pub cpu_utilization: u64,