From d2df50ab05a9d9a85a4b735786fe3f2b6e00186e Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期一, 26 一月 2026 22:19:17 +0800
Subject: [PATCH] 1.已把空指针和防护都补上了:创建消息失败直接返回并删除 action;spooling/发送/序列化都会跳过空消息并记录错误,避免再因 m_pSendMessage 为空导致崩溃或写出坏缓存。
---
SourceCode/Bond/Servo/PageRecipe.cpp | 46 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 8984870..841a96f 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -138,9 +138,12 @@
// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
for (int i = 0; i < static_cast<int>(vecRecipe.size()); ++i) {
const RecipeInfo& recipe = vecRecipe[i];
+ // 鍘熺▼搴忚姹侾PID鏈夊瓙閰嶆柟锛屽厛娉ㄩ噴
+ /*
if (recipe.vecDeviceList.empty() || recipe.vecDeviceList.size() > 6){
continue;
}
+ */
m_listPPID.InsertItem(i, _T("")); // 绗�0鍒楃┖鐧�
@@ -386,13 +389,12 @@
void CPageRecipe::OnBnClickedButtonNew()
{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- //CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
- //int nSel = pComboBox->GetCurSel();
- //SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nSel);
- //if (pEq == nullptr) {
- // return;
- //}
+ int rc = UX_CanExecute(L"recipe");
+ if (rc != 1) {
+ AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+ return;
+ }
+ UX_RecordAction(L"recipe");
CRecipeDeviceBindDlg dlg(this);
if (dlg.DoModal() == IDOK) {
@@ -452,6 +454,13 @@
void CPageRecipe::OnBnClickedButtonModify()
{
+ int rc = UX_CanExecute(L"recipe");
+ if (rc != 1) {
+ AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+ return;
+ }
+ UX_RecordAction(L"recipe");
+
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
if (pComboBox == nullptr || !::IsWindow(pComboBox->m_hWnd)) {
@@ -492,6 +501,13 @@
void CPageRecipe::OnBnClickedButtonDelete()
{
+ int rc = UX_CanExecute(L"recipe");
+ if (rc != 1) {
+ AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+ return;
+ }
+ UX_RecordAction(L"recipe");
+
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
POSITION pos = m_listPPID.GetFirstSelectedItemPosition();
if (!pos) {
@@ -518,6 +534,13 @@
void CPageRecipe::OnBnClickedButtonDeleteAll()
{
+ int rc = UX_CanExecute(L"recipe");
+ if (rc != 1) {
+ AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+ return;
+ }
+ UX_RecordAction(L"recipe");
+
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
if (IDYES != AfxMessageBox(_T("纭畾瑕佸垹闄ゅ叏閮ㄩ厤鏂硅褰曞悧锛�"), MB_YESNO | MB_ICONWARNING)) {
return;
@@ -778,4 +801,13 @@
}
}
return result;
+}
+
+BOOL CPageRecipe::PreTranslateMessage(MSG* pMsg)
+{
+ if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) {
+ return TRUE;
+ }
+
+ return CDialogEx::PreTranslateMessage(pMsg);
}
\ No newline at end of file
--
Gitblit v1.9.3