diff options
| author | 2025-02-07 08:44:07 +0100 | |
|---|---|---|
| committer | 2025-02-07 08:48:52 +0100 | |
| commit | 3c01854575bfe2f1ba880520d54b7c84f893e26d (patch) | |
| tree | 14cbbdc0af962422ad791b35ae43bb8254e40772 | |
| parent | 940a079d83f904bef0eb9514fce50cd0109219c9 (diff) | |
| download | iced-3c01854575bfe2f1ba880520d54b7c84f893e26d.tar.gz iced-3c01854575bfe2f1ba880520d54b7c84f893e26d.tar.bz2 iced-3c01854575bfe2f1ba880520d54b7c84f893e26d.zip | |
Fix system informations `cpu_brand` always being empty
This was caused by a misuse of the `global_cpu_info` function, which
does not contain a valid `cpu_brand` field.
To fix this, we now get the first cpu and return it's brand instead.
Fixes #2794
| -rw-r--r-- | winit/src/system.rs | 8 | 
1 files changed, 6 insertions, 2 deletions
| diff --git a/winit/src/system.rs b/winit/src/system.rs index 361135be..0b476773 100644 --- a/winit/src/system.rs +++ b/winit/src/system.rs @@ -17,7 +17,11 @@ pub(crate) fn information(      let mut system = System::new_all();      system.refresh_all(); -    let cpu = system.global_cpu_info(); +    let cpu_brand = system +        .cpus() +        .first() +        .map(|cpu| cpu.brand().to_string()) +        .unwrap_or_default();      let memory_used = sysinfo::get_current_pid()          .and_then(|pid| system.process(pid).ok_or("Process not found")) @@ -29,7 +33,7 @@ pub(crate) fn information(          system_kernel: System::kernel_version(),          system_version: System::long_os_version(),          system_short_version: System::os_version(), -        cpu_brand: cpu.brand().into(), +        cpu_brand,          cpu_cores: system.physical_core_count(),          memory_total: system.total_memory(),          memory_used, | 
