深度循环依赖项检查
This commit is contained in:
parent
88e31cac61
commit
d85b8afbb3
|
@ -7272,6 +7272,34 @@ void ChgjsonDlg::filter_tree_item(HTREEITEM item, const std::vector<HGITEM>& fil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool ChgjsonDlg::is_depend(const wchar_t* me, const wchar_t* parent, std::vector<std::wstring>* que)
|
||||||
|
{
|
||||||
|
std::vector<HGITEM>::iterator it = std::find(hg_items_.begin(), hg_items_.end(), me);
|
||||||
|
bool depend = false;
|
||||||
|
|
||||||
|
if (it != hg_items_.end())
|
||||||
|
{
|
||||||
|
for (auto& v : it->depend)
|
||||||
|
{
|
||||||
|
if (v.parent == parent)
|
||||||
|
{
|
||||||
|
depend = true;
|
||||||
|
if (que)
|
||||||
|
que->push_back(parent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
depend = is_depend(v.parent.c_str(), parent, que);
|
||||||
|
if (depend)
|
||||||
|
{
|
||||||
|
if (que)
|
||||||
|
que->push_back(v.parent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return depend;
|
||||||
|
}
|
||||||
|
|
||||||
// If you add a minimize button to your dialog, you will need the code below
|
// If you add a minimize button to your dialog, you will need the code below
|
||||||
// to draw the icon. For MFC applications using the document/view model,
|
// to draw the icon. For MFC applications using the document/view model,
|
||||||
|
@ -7833,19 +7861,23 @@ void ChgjsonDlg::OnBnClickedButton3()
|
||||||
di.parent = oper;
|
di.parent = oper;
|
||||||
|
|
||||||
// check recycle depend ...
|
// check recycle depend ...
|
||||||
std::vector<HGITEM>::iterator dpn = std::find(hg_items_.begin(), hg_items_.end(), oper);
|
std::vector<std::wstring> depend_stck;
|
||||||
if (dpn != hg_items_.end())
|
if(is_depend(oper, name.c_str(), &depend_stck))
|
||||||
{
|
//std::vector<HGITEM>::iterator dpn = std::find(hg_items_.begin(), hg_items_.end(), oper);
|
||||||
std::vector<DEPENDITEM>::iterator dpnd = std::find(dpn->depend.begin(), dpn->depend.end(), name.c_str());
|
//if (dpn != hg_items_.end())
|
||||||
if (dpnd != dpn->depend.end())
|
//{
|
||||||
|
// std::vector<DEPENDITEM>::iterator dpnd = std::find(dpn->depend.begin(), dpn->depend.end(), name.c_str());
|
||||||
|
// if (dpnd != dpn->depend.end())
|
||||||
{
|
{
|
||||||
|
for (int i = 1; i < depend_stck.size(); ++i)
|
||||||
|
name.insert(0, depend_stck[i] + L"--->");
|
||||||
name.insert(0, L" is already DEPEND on me(");
|
name.insert(0, L" is already DEPEND on me(");
|
||||||
name.insert(0, oper);
|
name.insert(0, oper);
|
||||||
name += L")! Delete me from it's depend queue first.";
|
name += L")! Delete me from it's depend queue first.";
|
||||||
::MessageBoxW(m_hWnd, name.c_str(), L"Recycle Depending", MB_ICONSTOP | MB_OK);
|
::MessageBoxW(m_hWnd, name.c_str(), L"Recycle Depending", MB_ICONSTOP | MB_OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
::GetWindowTextW(logic_.m_hWnd, oper, _countof(oper) - 1);
|
::GetWindowTextW(logic_.m_hWnd, oper, _countof(oper) - 1);
|
||||||
if (wcscmp(oper, L"between") == 0)
|
if (wcscmp(oper, L"between") == 0)
|
||||||
|
|
|
@ -137,6 +137,7 @@ protected:
|
||||||
void on_config_name_changed(const wchar_t* prev, const wchar_t* now);
|
void on_config_name_changed(const wchar_t* prev, const wchar_t* now);
|
||||||
HTREEITEM add_tree_item(const wchar_t* title, DWORD data, HTREEITEM parent = TVI_ROOT, HTREEITEM after = TVI_LAST);
|
HTREEITEM add_tree_item(const wchar_t* title, DWORD data, HTREEITEM parent = TVI_ROOT, HTREEITEM after = TVI_LAST);
|
||||||
void filter_tree_item(HTREEITEM item, const std::vector<HGITEM>& filter);
|
void filter_tree_item(HTREEITEM item, const std::vector<HGITEM>& filter);
|
||||||
|
bool is_depend(const wchar_t* me, const wchar_t* parent, std::vector<std::wstring>* que = NULL); // whether me depend on parent
|
||||||
|
|
||||||
public:
|
public:
|
||||||
afx_msg void OnTreeAddGroup();
|
afx_msg void OnTreeAddGroup();
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue