From eee1b76d18dfb7da3e290864c0c00c7c798c0ddc Mon Sep 17 00:00:00 2001 From: company-desktop-computer Date: Sun, 25 Oct 2026 11:05:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20selectEqu=20=E7=9A=84=20pszSearch=20?= =?UTF-8?q?=E5=88=A4=E7=A9=BA=E6=9D=A1=E4=BB=B6=E5=86=99=E5=8F=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #50 去掉早退后,赋值条件写成 if (!pszSearch),正好相反: - pszSearch == NULL("插入设备"、selectSingleEqu(NULL, ...)) 把 NULL 赋给 CString,Debug 版触发 ASSERT(AfxIsValidString) - pszSearch != NULL(selectCustomValve 传入 "闸阀 DN100") 预填的搜索词被清成空串,对话框打开后搜索框是空的 改为 if (pszSearch)。同时补上下面 CString sText(pszSearch) 的空判断, pszSearch 为 NULL 时构造 CString 同样会 ASSERT。 保持用调用者传入的 pszSearch 判断设备子类型,而不是 dlg.m_sSearch: 后者在 DoModal 之后可能已被用户改成别的搜索词。 --- SourceCode/Code2026/PipelineCmd/EquLibDlg.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SourceCode/Code2026/PipelineCmd/EquLibDlg.cpp b/SourceCode/Code2026/PipelineCmd/EquLibDlg.cpp index a4de393..f4e8136 100644 --- a/SourceCode/Code2026/PipelineCmd/EquLibDlg.cpp +++ b/SourceCode/Code2026/PipelineCmd/EquLibDlg.cpp @@ -718,7 +718,9 @@ AecDbEwEquipment * CEquLibDlg::selectEqu(LPCTSTR pszSearch dlg.m_bCheck2DFlag = bUseFangle; dlg.m_bUseFangle = b2DCheck; dlg.m_bSearch = TRUE; - if (!pszSearch) + //pszSearch 为空表示"插入设备"这类不需要预填搜索词的入口, + //此时对话框照常打开,只是搜索框留空;不能早退,也不能把 NULL 赋给 CString + if (pszSearch) dlg.m_sSearch = pszSearch; else dlg.m_sSearch = _T(""); @@ -733,7 +735,8 @@ AecDbEwEquipment * CEquLibDlg::selectEqu(LPCTSTR pszSearch //设置子类型,后续可增加类型 extern AecEqui::VlvType g_vlvType[]; - CString sText(pszSearch); + //按调用者传入的关键字判断设备子类型,pszSearch 可能为 NULL + CString sText(pszSearch == NULL ? _T("") : pszSearch); if (sText.Find(_T("阀")) != -1) { pEqu->GetSpecialtyData()->SetAt(KEY_SUBRUNTIME, eValve); -- 2.54.0