manio143 / ShadowsOfShadows

RPG game
MIT License
0 stars 0 forks source link

'Collection was modified' during GraphicsResource.Finalize() #66

Open manio143 opened 7 years ago

manio143 commented 7 years ago

Czasami zdarza się coś takiego podczas korzystania z MenuConsole

Unhandled Exception:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
  at System.ThrowHelper.ThrowInvalidOperationException (System.ExceptionResource resource) [0x0000b] in <a07d6bf484a54da2861691df91
0339b1>:0
  at System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[TKey,TValue].MoveNext () [0x00013] in <a07d6bf484a54da2861691
df910339b1>:0
  at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDeleteRenderTarget (Microsoft.Xna.Framework.Graphics.Texture renderTar
get) [0x000d1] in <09a4fa86cd2849b6aff4187c85884630>:0
  at Microsoft.Xna.Framework.Graphics.RenderTarget2D.<Dispose>b__c () [0x00006] in <09a4fa86cd2849b6aff4187c85884630>:0
  at Microsoft.Xna.Framework.Threading.BlockOnUIThread (System.Action action) [0x0003b] in <09a4fa86cd2849b6aff4187c85884630>:0
  at Microsoft.Xna.Framework.Graphics.RenderTarget2D.Dispose (System.Boolean disposing) [0x0001a] in <09a4fa86cd2849b6aff4187c85884
630>:0
  at Microsoft.Xna.Framework.Graphics.GraphicsResource.Finalize () [0x00000] in <09a4fa86cd2849b6aff4187c85884630>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Collection was modified; enumeration operation may not execute
.
  at System.ThrowHelper.ThrowInvalidOperationException (System.ExceptionResource resource) [0x0000b] in <a07d6bf484a54da2861691df91
0339b1>:0
  at System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[TKey,TValue].MoveNext () [0x00013] in <a07d6bf484a54da2861691
df910339b1>:0
  at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDeleteRenderTarget (Microsoft.Xna.Framework.Graphics.Texture renderTar
get) [0x000d1] in <09a4fa86cd2849b6aff4187c85884630>:0
  at Microsoft.Xna.Framework.Graphics.RenderTarget2D.<Dispose>b__c () [0x00006] in <09a4fa86cd2849b6aff4187c85884630>:0
  at Microsoft.Xna.Framework.Threading.BlockOnUIThread (System.Action action) [0x0003b] in <09a4fa86cd2849b6aff4187c85884630>:0
  at Microsoft.Xna.Framework.Graphics.RenderTarget2D.Dispose (System.Boolean disposing) [0x0001a] in <09a4fa86cd2849b6aff4187c85884
630>:0
  at Microsoft.Xna.Framework.Graphics.GraphicsResource.Finalize () [0x00000] in <09a4fa86cd2849b6aff4187c85884630>:0
dkaluza commented 7 years ago

ResetView() modyfikuje kolekcje kiedy jest wywołane w ProcessKeyboard w Messages

manio143 commented 7 years ago

ResetView istnieje w Equipment i Chest Message, żeby móc "dynamicznie" usuwać elementy po ich wybraniu. Ale wydaje mk się że modufikuje te kolekcje w sposób "legalny". Ten błąd mówi, że podczas usuwania śmieci w metodzie Finalize na GraphicsResource, kiedy ta się iteruje po pewnym słowniku to jest on zewnętrznie modyfikowany.