starik222 / BooruDatasetTagManager

MIT License
1.43k stars 123 forks source link

Unhandled exception (Index was out of range) on some tags in dataset #98

Closed Darkenlord1 closed 10 months ago

Darkenlord1 commented 10 months ago

When there are tags like those in one file (all together):

abigail williams (fate), abigail williams (swimsuit foreigner) (fate), abigail williams (swimsuit foreigner) (third ascension) (fate)

When getting rid of all except one - works fine.

Getting this error: image

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.AggregateException: One or more errors occurred. (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index'))
 ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
   at BooruDatasetTagManager.EditableTagList.DeduplicateTags() in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\EditableTagList.cs:line 229
   at BooruDatasetTagManager.EditableTagList.ToString() in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\EditableTagList.cs:line 89
   at System.String.JoinCore(ReadOnlySpan`1 separator, Object[] values)
   at BooruDatasetTagManager.DatasetManager.DataItem.ToString() in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\DatasetManager.cs:line 420
   at BooruDatasetTagManager.DatasetManager.DataItem.GetHashCode() in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\DatasetManager.cs:line 425
   at BooruDatasetTagManager.DatasetManager.DataItem.GetTagsFromFile() in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\DatasetManager.cs:line 416
   at BooruDatasetTagManager.DatasetManager.DataItem.LoadData(String imagePath, Int32 imageSize) in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\DatasetManager.cs:line 382
   at BooruDatasetTagManager.DatasetManager.<>c__DisplayClass24_0.<LoadFromFolder>b__2(String x) in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\DatasetManager.cs:line 254
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
   at System.Linq.Parallel.SpoolingTask.SpoolForAll[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, TaskScheduler taskScheduler)
   at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
   at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
   at System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
   at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
   at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
   at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
   at System.Linq.Parallel.ForAllOperator`1.RunSynchronously()
   at BooruDatasetTagManager.DatasetManager.LoadFromFolder(String folder) in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\DatasetManager.cs:line 0
   at BooruDatasetTagManager.MainForm.openFolderToolStripMenuItem_Click(Object sender, EventArgs e) in J:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\Form1.cs:line 121
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
Xiahussheng commented 10 months ago

I'm having the same problem.

starik222 commented 10 months ago

Fixed in 2.0.2

rzfw commented 10 months ago

Hi, Still getting this issue when trying to create a new tag on an individual image. hovering over the empty image tag box causes the error to spam appear

image

System.ComponentModel.InvalidAsynchronousStateException: List desynchronization detected!
   at BooruDatasetTagManager.EditableTagList.OnListChanged(ListChangedEventArgs ev) in M:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\EditableTagList.cs:line 551
   at BooruDatasetTagManager.EditableTagList.OnInsertComplete(Int32 index, Object value) in M:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\EditableTagList.cs:line 581
   at System.Collections.CollectionBase.System.Collections.IList.Insert(Int32 index, Object value)
   at BooruDatasetTagManager.EditableTagList.InsertNew(Int32 index) in M:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\EditableTagList.cs:line 437
   at BooruDatasetTagManager.MainForm.AddNewRow() in M:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\Form1.cs:line 358
   at BooruDatasetTagManager.MainForm.BtnAddTag_Clicked(Object sender, EventArgs e) in M:\Dev\BooruDatasetTagManager\BooruDatasetTagManager\Form1.cs:line 319
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)