重构添加统一异常处理

This commit is contained in:
xinzhu.yin
2026-04-20 15:34:45 +08:00
parent 2e92b48496
commit b1b14c2d49
8 changed files with 114 additions and 61 deletions

View File

@@ -273,7 +273,7 @@ def _clear_custom_result_row(self, item_id, row_no):
def _run_custom_row_single_step(self, item_id, row_no):
"""后台执行客户模板单步测试"""
try:
self.root.after(0, lambda: self.status_var.set(f"单步测试第 {row_no} 行..."))
self._dispatch_ui(self.status_var.set, f"单步测试第 {row_no} 行...")
self.log_gui.log(f"开始单步测试第 {row_no}")
self.config.set_current_pattern("custom")
@@ -296,7 +296,7 @@ def _run_custom_row_single_step(self, item_id, row_no):
if row_no > len(converted_params):
self.log_gui.log(f"❌ 行号超出 pattern 范围: {row_no}/{len(converted_params)}")
self.root.after(0, lambda: self.status_var.set("单步测试失败:行号超范围"))
self._dispatch_ui(self.status_var.set, "单步测试失败:行号超范围")
return
self.ucd.set_ucd_params(temp_config)
@@ -331,17 +331,16 @@ def _run_custom_row_single_step(self, item_id, row_no):
"Pe": pe,
}
self.root.after(
0,
lambda: self._update_custom_result_row(item_id, row_no, row_data),
self._dispatch_ui(
self._update_custom_result_row, item_id, row_no, row_data
)
self.log_gui.log(f"✓ 第 {row_no} 行单步测试完成并已覆盖")
self.root.after(0, lambda: self.status_var.set(f"{row_no} 行单步测试完成"))
self._dispatch_ui(self.status_var.set, f"{row_no} 行单步测试完成")
except Exception as e:
self.log_gui.log(f"❌ 单步测试失败: {str(e)}")
self.root.after(0, lambda: self.status_var.set("单步测试失败"))
self._dispatch_ui(self.status_var.set, "单步测试失败")
def _update_custom_result_row(self, item_id, row_no, result_data):

View File

@@ -1064,37 +1064,26 @@ class PQDebugPanel:
def _enable_test_button(self, test_type, test_item):
"""启用测试按钮"""
dispatch = self.app._dispatch_ui
if test_type == "screen_module":
if test_item == "gamma":
self.app.root.after(0, lambda: self.screen_test_btn.config(state=tk.NORMAL))
dispatch(self.screen_test_btn.config, state=tk.NORMAL)
elif test_item == "rgb":
self.app.root.after(0, lambda: self.screen_rgb_test_btn.config(state=tk.NORMAL))
dispatch(self.screen_rgb_test_btn.config, state=tk.NORMAL)
elif test_type == "sdr_movie":
if test_item == "gamma":
self.app.root.after(
0, lambda: self.sdr_gamma_test_btn.config(state=tk.NORMAL)
)
dispatch(self.sdr_gamma_test_btn.config, state=tk.NORMAL)
elif test_item == "accuracy":
self.app.root.after(
0, lambda: self.sdr_accuracy_test_btn.config(state=tk.NORMAL)
)
dispatch(self.sdr_accuracy_test_btn.config, state=tk.NORMAL)
elif test_item == "rgb":
self.app.root.after(
0, lambda: self.sdr_rgb_test_btn.config(state=tk.NORMAL)
)
dispatch(self.sdr_rgb_test_btn.config, state=tk.NORMAL)
elif test_type == "hdr_movie":
if test_item == "eotf":
self.app.root.after(
0, lambda: self.hdr_eotf_test_btn.config(state=tk.NORMAL)
)
dispatch(self.hdr_eotf_test_btn.config, state=tk.NORMAL)
elif test_item == "accuracy":
self.app.root.after(
0, lambda: self.hdr_accuracy_test_btn.config(state=tk.NORMAL)
)
dispatch(self.hdr_accuracy_test_btn.config, state=tk.NORMAL)
elif test_item == "rgb":
self.app.root.after(
0, lambda: self.hdr_rgb_test_btn.config(state=tk.NORMAL)
)
dispatch(self.hdr_rgb_test_btn.config, state=tk.NORMAL)
# ==================== 辅助方法 ====================