diff --git a/src/EvoSC.Modules/Util/SortedModuleCollection.cs b/src/EvoSC.Modules/Util/SortedModuleCollection.cs index 162271455..3985da2ca 100644 --- a/src/EvoSC.Modules/Util/SortedModuleCollection.cs +++ b/src/EvoSC.Modules/Util/SortedModuleCollection.cs @@ -55,11 +55,7 @@ private List GetSortedModules() selected = dependent.Key; } - if (selected != null) - { - dependencyGraph.Remove(selected); - } - else + if (selected == null) { break; } @@ -78,6 +74,11 @@ private static void RemoveDependent(DependencyGraph dependencyGraph, KeyValuePai dependencies.Value.Remove(dependent.Key); } } + + if (dependencyGraph.ContainsKey(dependent.Key)) + { + dependencyGraph.Remove(dependent.Key); + } } private DependencyGraph MakeDependencyGraph()