Skip to content

Commit

Permalink
Fix System.ArgumentOutOfRangeException in workers
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Nov 5, 2021
1 parent 54f6c9d commit abf1231
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TVRename/Forms/BulkAddMovies/BulkAddMovie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private void bwIdentify_ProgressChanged(object sender, [NotNull] ProgressChanged
{
lvFMNewShows.Update();

pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0,100);
lblStatusLabel.Text = ((PossibleNewMovie)e.UserState).RefinedHint;
UpdateListItem((PossibleNewMovie)e.UserState, false);
}
Expand All @@ -619,7 +619,7 @@ private void bwIdentify_RunWorkerCompleted(object sender, RunWorkerCompletedEven

private void bwRescan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatusLabel.Text = e.UserState.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/CollectionsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void BwScan_DoWork(object sender, DoWorkEventArgs e)

private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/DuplicateMovieFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void ProcessMovie([NotNull] MovieConfiguration movie)

private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/MergedEpisodeFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private void BwScan_DoWork([NotNull] object sender, DoWorkEventArgs e)

private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/OrphanFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private static bool HasEpisode([NotNull] IEnumerable<ProcessedEpisode> showSeaso

private void BwRescan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/RecommendationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void BwScan_DoWork(object sender, DoWorkEventArgs e)

private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState?.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/SettingsReview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void BwScan_DoWork(object sender, DoWorkEventArgs e)

private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState.ToString();
}

Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/ShowSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ private void BwRescan_DoWork(object sender, DoWorkEventArgs e)

private void BwRescan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e)
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Value = e.ProgressPercentage.Between(0, 100);
lblStatus.Text = e.UserState.ToString();
}

Expand Down
14 changes: 14 additions & 0 deletions TVRename/Utility/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ public static class Helpers

public static bool InDebug() => Debugger.IsAttached;


public static int Between(this int value, int min, int max)
{
if (value < min)
{
return min;
}
if (value > max)
{
return max;
}
return value;
}

public static bool In<T>([CanBeNull] this T item, [NotNull] params T[] items)
{
if (items == null)
Expand Down

0 comments on commit abf1231

Please sign in to comment.