From f8c28a2e7e6f4907d51dd9286ea997faef82135f Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Fri, 17 Jan 2020 20:17:52 -0600 Subject: [PATCH] Minor tweak to organization of CommitTransaction --- IPA.Loader/Loader/PluginManager.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 4e4a526e..3356eba1 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -81,19 +81,15 @@ namespace IPA.Loader internal static Task CommitTransaction(StateTransitionTransaction transaction) { - if (UnityGame.OnMainThread) - return CommitTransactionInternal(transaction); - else - return UnityMainThreadTaskScheduler.Factory.StartNew(() => CommitTransactionInternal(transaction)).Unwrap(); - } - private static Task CommitTransactionInternal(StateTransitionTransaction transaction) - { + if (!UnityGame.OnMainThread) + return UnityMainThreadTaskScheduler.Factory.StartNew(() => CommitTransaction(transaction)).Unwrap(); + lock (commitTransactionLockObject) { if (transaction.CurrentlyEnabled.Except(AllPlugins) .Concat(AllPlugins.Except(transaction.CurrentlyEnabled)).Any() || transaction.CurrentlyDisabled.Except(DisabledPlugins) - .Concat(DisabledPlugins.Except(transaction.DisabledPlugins)).Any()) + .Concat(DisabledPlugins.Except(transaction.CurrentlyDisabled)).Any()) { // ensure that the transaction's base state reflects the current state, otherwise throw throw new InvalidOperationException("Transaction no longer resembles the current state of plugins"); }