fix: selectEqu 的 pszSearch 判空条件写反

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 之后可能已被用户改成别的搜索词。
This commit is contained in:
company-desktop committed 2026-10-25 11:05:18 +08:00
1 parent f084e20fc6
commit eee1b76d18
1 file changed
+5 -2
@@ -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);