Prevents duplicated event hooks.

This commit is contained in:
2022-11-12 00:52:44 +08:00
parent bca71982e5
commit 8af09a7167

View File

@@ -42,6 +42,7 @@ namespace Cryville.Crtr {
if (_use[proxy.Target] > 0)
throw new InvalidOperationException("Input already assigned");
if (proxy.Source != null) {
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
proxy.Source.Value.Handler.OnInput += OnInput;
_tproxies.Add(proxy.Target, proxy);
_sproxies.Add(proxy.Source.Value, proxy);