libertyernie / brawltools

BrawlBox and BrawlLib
http://forums.kc-mm.com/index.php?topic=67847.0
142 stars 31 forks source link

Collection was modified; enumeration operation may not execute #156

Closed Ebola16 closed 6 years ago

Ebola16 commented 6 years ago

Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List1.Enumerator.MoveNextRare() at System.Collections.Generic.List1.Enumerator.MoveNext() at BrawlLib.SSBB.ResourceNodes.ResourceNode.FindChild(String path, Boolean searchChildren) at BrawlLib.SSBB.ResourceNodes.ResourceNode.FindChild(String path, Boolean searchChildren) at BrawlLib.SSBB.ResourceNodes.ResourceNode.FindChild(String path, Boolean searchChildren) at BrawlLib.SSBB.ResourceNodes.ResourceNode.FindChild(String path, Boolean searchChildren) at BrawlLib.SSBB.ResourceNodes.MDL0TextureNode.Load(Int32 index, Int32 program) at BrawlLib.SSBB.ResourceNodes.MDL0TextureNode.Prepare(MDL0MaterialRefNode mRef, Int32 shaderProgramHandle, String palette) at System.Windows.Forms.TexCoordRenderer.SetTarget(MDL0MaterialRefNode texture) at System.Windows.Forms.TexCoordRenderer.set_TargetNode(MDL0MaterialRefNode value) at System.Windows.Forms.TexCoordControl.set_TargetNode(MDL0MaterialRefNode value) at BrawlBox.MainForm.resourceTree_SelectionChanged(Object sender, EventArgs e) in C:\Users\Ryan!\Source\Repos\brawltools\BrawlBox\UI\MainForm.cs:line 490 at System.EventHandler.Invoke(Object sender, EventArgs e) at BrawlBox.ResourceTree.set_SelectedNode(TreeNode value) in C:\Users\Ryan!\Source\Repos\brawltools\BrawlBox\UI\ResourceTree.cs:line 112 at BrawlBox.ResourceTree.OnAfterSelect(TreeViewEventArgs e) in C:\Users\Ryan!\Source\Repos\brawltools\BrawlBox\UI\ResourceTree.cs:line 210 at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv) at System.Windows.Forms.TreeView.WmNotify(Message& m) at System.Windows.Forms.TreeView.WndProc(Message& m) at BrawlBox.ResourceTree.WndProc(Message& m) in C:\Users\Ryan!\Source\Repos\brawltools\BrawlBox\UI\ResourceTree.cs:line 181 at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Steps to reproduce:

  1. Download and extract Enumeration operation may not execute.zip
  2. Open FitMarth01.pcs
  3. Replace each material in numerical order: Replace the first material with Material#25 Replace the second material with Material#27 Replace the third material with Material#30 Replace the fourth material with Material#35 Replace the fifth material with Material#35
  4. View the material reference of the last material.
  5. Observe above error.

Also, if you want the completed version of the attached Corrin (Female) import, it can be found here http://forums.kc-mm.com/Gallery/BrawlView.php?Number=214921

libertyernie commented 6 years ago

It looks like when BrawlBox is in the process of showing the material reference, it loads one of the materials (not sure if it's that one or not) which causes a Palettes group to be added to the model (it didn't have one before) and that throws off the foreach loop.

I could probably make a copy of the collection before I go through it - any situation where that would change the result would, at the moment, result in a crash, so I think I'm OK.

In the meantime, it should work if you replace the materials, close the file, and open it again.

Ebola16 commented 6 years ago

Yes, closing and reopening the file does work around the issue.

libertyernie commented 6 years ago

Should be fixed now.

Ebola16 commented 6 years ago

LGTM, thanks!