113 lines
3.6 KiB
Diff
113 lines
3.6 KiB
Diff
From 4d39214b78a856c591b76f445927f7d0edf8f5b7 Mon Sep 17 00:00:00 2001
|
|
From: wangtaozhi <wangtaozhi@kylinsec.com.cn>
|
|
Date: Mon, 12 Jun 2023 10:47:23 +0800
|
|
Subject: [PATCH] fix(systeminfo): Adjusting the reading method of cpu
|
|
information,Resolve program crash issue when exiting the program
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
- 调整cup信息读取方式
|
|
- 解决程序退出时连接wm_window_changed_信号的对象已经析构导致程序崩溃问题
|
|
|
|
Fixes #6911
|
|
---
|
|
plugins/keybinding/system-shortcut.h | 2 +-
|
|
plugins/systeminfo/systeminfo-hardware.cpp | 33 +++++++++++++++++-----
|
|
plugins/systeminfo/systeminfo-hardware.h | 2 ++
|
|
3 files changed, 29 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/plugins/keybinding/system-shortcut.h b/plugins/keybinding/system-shortcut.h
|
|
index 367f33a..b6f3a7d 100644
|
|
--- a/plugins/keybinding/system-shortcut.h
|
|
+++ b/plugins/keybinding/system-shortcut.h
|
|
@@ -39,7 +39,7 @@ struct SystemShortCut
|
|
sigc::connection connection;
|
|
};
|
|
|
|
-class SystemShortCuts
|
|
+class SystemShortCuts: public sigc::trackable
|
|
{
|
|
public:
|
|
SystemShortCuts();
|
|
diff --git a/plugins/systeminfo/systeminfo-hardware.cpp b/plugins/systeminfo/systeminfo-hardware.cpp
|
|
index 66b7b49..7001b86 100644
|
|
--- a/plugins/systeminfo/systeminfo-hardware.cpp
|
|
+++ b/plugins/systeminfo/systeminfo-hardware.cpp
|
|
@@ -26,6 +26,8 @@ namespace Kiran
|
|
#define CPUINFO_FILE "/proc/cpuinfo"
|
|
#define CPUINFO_KEY_DELIMITER ':'
|
|
#define CPUINFO_KEY_MODEL "model name"
|
|
+//龙芯cpuinfo中为大写
|
|
+#define CPUINFO_KEY_MODEL_LS "Model Name"
|
|
#define CPUINFO_KEY_PROCESSOR "processor"
|
|
|
|
#define MEMINFO_FILE "/proc/meminfo"
|
|
@@ -82,18 +84,31 @@ HardwareInfo SystemInfoHardware::get_hardware_info()
|
|
return hardware_info;
|
|
}
|
|
|
|
-CPUInfo SystemInfoHardware::get_cpu_info()
|
|
+CPUInfo SystemInfoHardware::merge_cpu_infos(const std::vector<CPUInfo> &cpu_infos)
|
|
{
|
|
- auto cpu_info = this->get_cpu_info_by_cmd();
|
|
-
|
|
- if (cpu_info.cores_number == 0)
|
|
+ CPUInfo cpu_info;
|
|
+ for(auto& iter : cpu_infos)
|
|
{
|
|
- cpu_info = this->read_cpu_info_by_conf();
|
|
+ if(cpu_info.model.empty())
|
|
+ {
|
|
+ cpu_info.model = iter.model;
|
|
+ }
|
|
+ if(cpu_info.cores_number == 0)
|
|
+ {
|
|
+ cpu_info.cores_number = iter.cores_number;
|
|
+ }
|
|
}
|
|
-
|
|
return cpu_info;
|
|
}
|
|
|
|
+CPUInfo SystemInfoHardware::get_cpu_info()
|
|
+{
|
|
+ std::vector<CPUInfo> cpu_infos;
|
|
+ cpu_infos.push_back(this->get_cpu_info_by_cmd());
|
|
+ cpu_infos.push_back(this->read_cpu_info_by_conf());
|
|
+ return this->merge_cpu_infos(cpu_infos);
|
|
+}
|
|
+
|
|
CPUInfo SystemInfoHardware::get_cpu_info_by_cmd()
|
|
{
|
|
// 低版本不支持-J选项
|
|
@@ -140,7 +155,11 @@ CPUInfo SystemInfoHardware::read_cpu_info_by_conf()
|
|
{
|
|
CPUInfo cpu_info;
|
|
auto cpu_maps = this->parse_info_file(CPUINFO_FILE, CPUINFO_KEY_DELIMITER);
|
|
-
|
|
+ //适配龙芯架构
|
|
+ if(cpu_info.model.empty())
|
|
+ {
|
|
+ cpu_info.model = cpu_maps[CPUINFO_KEY_MODEL_LS];
|
|
+ }
|
|
cpu_info.model = cpu_maps[CPUINFO_KEY_MODEL];
|
|
if (cpu_maps.find(CPUINFO_KEY_PROCESSOR) != cpu_maps.end())
|
|
{
|
|
diff --git a/plugins/systeminfo/systeminfo-hardware.h b/plugins/systeminfo/systeminfo-hardware.h
|
|
index 7aa25c4..2e95382 100644
|
|
--- a/plugins/systeminfo/systeminfo-hardware.h
|
|
+++ b/plugins/systeminfo/systeminfo-hardware.h
|
|
@@ -112,6 +112,8 @@ private:
|
|
CPUInfo get_cpu_info_by_cmd();
|
|
// 如果命令获取失败,则直接读取配置文件
|
|
CPUInfo read_cpu_info_by_conf();
|
|
+ // 合并读取信息
|
|
+ CPUInfo merge_cpu_infos(const std::vector<CPUInfo> &cpu_infos);
|
|
|
|
MemInfo get_mem_info();
|
|
void set_env();
|
|
--
|
|
2.40.1.windows.1
|
|
|