From d5edc3acd3ae5ca7109d874bb0a8842d972fc0b3 Mon Sep 17 00:00:00 2001 From: neuecc Date: Mon, 1 Jun 2020 13:51:37 +0900 Subject: [PATCH] guard for trigger invalid ops --- .../Plugins/UniTask/Runtime/TriggerEvent.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/TriggerEvent.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/TriggerEvent.cs index 743727d..153753c 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/TriggerEvent.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/TriggerEvent.cs @@ -24,7 +24,6 @@ namespace Cysharp.Threading.Tasks bool preserveRemoveSelf; ITriggerHandler iteratingNode; - void LogError(Exception ex) { #if UNITY_2018_3_OR_NEWER @@ -36,6 +35,11 @@ namespace Cysharp.Threading.Tasks public void SetResult(T value) { + if (iteratingNode != null) + { + throw new InvalidOperationException("Can not trigger itself in iterating."); + } + var h = head; while (h != null) { @@ -75,6 +79,11 @@ namespace Cysharp.Threading.Tasks public void SetCanceled(CancellationToken cancellationToken) { + if (iteratingNode != null) + { + throw new InvalidOperationException("Can not trigger itself in iterating."); + } + var h = head; while (h != null) { @@ -105,6 +114,11 @@ namespace Cysharp.Threading.Tasks public void SetCompleted() { + if (iteratingNode != null) + { + throw new InvalidOperationException("Can not trigger itself in iterating."); + } + var h = head; while (h != null) { @@ -135,6 +149,11 @@ namespace Cysharp.Threading.Tasks public void SetError(Exception exception) { + if (iteratingNode != null) + { + throw new InvalidOperationException("Can not trigger itself in iterating."); + } + var h = head; while (h != null) {