From 622ea7d387698361d1349a7fd221ce83cf6d1632 Mon Sep 17 00:00:00 2001 From: raiti-chan Date: Mon, 12 Dec 2022 18:49:32 +0900 Subject: [PATCH] Fix validation methods to avoid infinite loops. --- .../Editor/Inspector/MenuInstallerEditor.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Packages/nadena.dev.modular-avatar/Editor/Inspector/MenuInstallerEditor.cs b/Packages/nadena.dev.modular-avatar/Editor/Inspector/MenuInstallerEditor.cs index c7dba388..b9566fe1 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Inspector/MenuInstallerEditor.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Inspector/MenuInstallerEditor.cs @@ -205,9 +205,12 @@ namespace nadena.dev.modular_avatar.core.editor return _avatarMenus == null || _avatarMenus.Contains(menu); } - private static ValidateExpressionMenuIconResult ValidateExpressionMenuIcon(VRCExpressionsMenu menu) + private static ValidateExpressionMenuIconResult ValidateExpressionMenuIcon(VRCExpressionsMenu menu, HashSet visitedMenus = null) { if (menu == null) return ValidateExpressionMenuIconResult.Success; + if (visitedMenus == null) visitedMenus = new HashSet(); + if (visitedMenus.Contains(menu)) return ValidateExpressionMenuIconResult.Success; + visitedMenus.Add(menu); foreach (VRCExpressionsMenu.Control control in menu.controls) { @@ -224,7 +227,7 @@ namespace nadena.dev.modular_avatar.core.editor // SubMenu 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; }