Skip to content

Commit

Permalink
Improve equality check so it handles null objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra authored and Banane9 committed Jun 26, 2024
1 parent 8650c1f commit 7c4af14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MonkeyLoader.Resonite.Integration/FieldExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static Action<IChangeable> SyncWithConfigKey<T>(this IField<T> field, IDe

void FieldChangedHandler(IChangeable _)
{
if (field.Value.Equals(configKey.GetValue())) return;
if (Equals(field.Value, configKey.GetValue())) return;
if (!allowWriteBack || !configKey.TrySetValue(field.Value, eventLabel))
{
field.World.RunSynchronously(() => field.Value = configKey.GetValue()!);
Expand All @@ -31,7 +31,7 @@ void ConfigKeyChangedHandler(object sender, ConfigKeyChangedEventArgs<T> args)
configKey.Changed -= ConfigKeyChangedHandler;
return;
}
if (field.Value.Equals(configKey.GetValue())) return;
if (Equals(field.Value, configKey.GetValue())) return;
field.World.RunSynchronously(() => field.Value = configKey.GetValue()!);
}

Expand Down

0 comments on commit 7c4af14

Please sign in to comment.