fix bug(warning when no items configured)

This commit is contained in:
gb 2022-12-09 15:37:18 +08:00
parent 858a6f4b16
commit fbe5cc77eb
2 changed files with 17 additions and 9 deletions

View File

@ -410,7 +410,12 @@ std::wstring CDlgMgr::export_config(bool *ok, bool used_in_code, int code_ver)
known_file_util::IJsonW * jsn = known_file_util::create_jsonW(),
* child = known_file_util::create_jsonW();
wchar_t text[256] = { 0 };
bool result = false;
if (!ok)
ok = &result;
*ok = false;
if (!used_in_code)
{
WORD vid_f = vid_pid_edit_value(GetDlgItem(IDC_EDIT_VID_SRC)->m_hWnd),
@ -418,41 +423,38 @@ std::wstring CDlgMgr::export_config(bool *ok, bool used_in_code, int code_ver)
vid_t = vid_pid_edit_value(GetDlgItem(IDC_EDIT_VID_TO)->m_hWnd),
pid_t = vid_pid_edit_value(GetDlgItem(IDC_EDIT_PID_TO)->m_hWnd),
port = 0;
bool result = false, report = is_checked(GetDlgItem(IDC_CHECK2));
bool report = is_checked(GetDlgItem(IDC_CHECK2));
BYTE ip1 = 0, ip2 = 0, ip3 = 0, ip4 = 0;
if (!ok)
ok = &result;
*ok = false;
if (!vid_f)
{
GotoDlgCtrl(GetDlgItem(IDC_EDIT_VID_SRC));
jsn->release();
return L"请重新输入 源VID!";
}
if (!pid_f)
{
GotoDlgCtrl(GetDlgItem(IDC_EDIT_PID_SRC));
jsn->release();
return L"请重新输入 源PID!";
}
if (!vid_t)
{
GotoDlgCtrl(GetDlgItem(IDC_EDIT_VID_TO));
jsn->release();
return L"请重新输入 目标VID!";
}
if (!pid_t)
{
GotoDlgCtrl(GetDlgItem(IDC_EDIT_PID_TO));
jsn->release();
return L"请重新输入 目标PID!";
}
if (list_.GetItemCount() == 0)
return L"没有输入有效的测试项目!";
if (report)
{
ip_.GetAddress(ip1, ip2, ip3, ip4);
@ -477,8 +479,14 @@ std::wstring CDlgMgr::export_config(bool *ok, bool used_in_code, int code_ver)
}
jsn->set_value(L"global", child);
}
child->release();
if (list_.GetItemCount() == 0)
{
jsn->release();
return L"没有输入有效的测试项目!";
}
for (size_t i = 0; i < list_.GetItemCount(); ++i)
{
page_config::ITEM item;