mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-21 14:00:08 +08:00
Fix validation methods to avoid infinite loops.
This commit is contained in:
parent
5b97455c0f
commit
622ea7d387
@ -205,9 +205,12 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
return _avatarMenus == null || _avatarMenus.Contains(menu);
|
return _avatarMenus == null || _avatarMenus.Contains(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ValidateExpressionMenuIconResult ValidateExpressionMenuIcon(VRCExpressionsMenu menu)
|
private static ValidateExpressionMenuIconResult ValidateExpressionMenuIcon(VRCExpressionsMenu menu, HashSet<VRCExpressionsMenu> visitedMenus = null)
|
||||||
{
|
{
|
||||||
if (menu == null) return ValidateExpressionMenuIconResult.Success;
|
if (menu == null) return ValidateExpressionMenuIconResult.Success;
|
||||||
|
if (visitedMenus == null) visitedMenus = new HashSet<VRCExpressionsMenu>();
|
||||||
|
if (visitedMenus.Contains(menu)) return ValidateExpressionMenuIconResult.Success;
|
||||||
|
visitedMenus.Add(menu);
|
||||||
|
|
||||||
foreach (VRCExpressionsMenu.Control control in menu.controls)
|
foreach (VRCExpressionsMenu.Control control in menu.controls)
|
||||||
{
|
{
|
||||||
@ -224,7 +227,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
// SubMenu
|
// SubMenu
|
||||||
if (control.type != VRCExpressionsMenu.Control.ControlType.SubMenu) continue;
|
if (control.type != VRCExpressionsMenu.Control.ControlType.SubMenu) continue;
|
||||||
ValidateExpressionMenuIconResult subMenuResult = ValidateExpressionMenuIcon(control.subMenu);
|
ValidateExpressionMenuIconResult subMenuResult = ValidateExpressionMenuIcon(control.subMenu, visitedMenus);
|
||||||
if (subMenuResult != ValidateExpressionMenuIconResult.Success) return subMenuResult;
|
if (subMenuResult != ValidateExpressionMenuIconResult.Success) return subMenuResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user