Skip to content

Commit dbb293d

Browse files
committed
Fix system informations cpu_brand always being empty
This was caused by a misuse of the `global_cpu_info` function, which was does not contain a valid `cpu_brand` field. To fix this, we now get the first cpu and return it's brand instead. Fixes iced-rs#2794
1 parent 940a079 commit dbb293d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

winit/src/system.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ pub(crate) fn information(
1717
let mut system = System::new_all();
1818
system.refresh_all();
1919

20-
let cpu = system.global_cpu_info();
20+
let cpu_brand = system
21+
.cpus()
22+
.first()
23+
.map(|cpu| cpu.brand().to_string())
24+
.unwrap_or_default();
2125

2226
let memory_used = sysinfo::get_current_pid()
2327
.and_then(|pid| system.process(pid).ok_or("Process not found"))
@@ -29,7 +33,7 @@ pub(crate) fn information(
2933
system_kernel: System::kernel_version(),
3034
system_version: System::long_os_version(),
3135
system_short_version: System::os_version(),
32-
cpu_brand: cpu.brand().into(),
36+
cpu_brand,
3337
cpu_cores: system.physical_core_count(),
3438
memory_total: system.total_memory(),
3539
memory_used,

0 commit comments

Comments
 (0)